Python Index Page 1

How to find the mime type of a file in Python?

Here are some example on how to guess the mime type of a file using python. The first example uses the filename only and the second example opens the file to guess the mime type.

Python Index Page 1

pip: six issue when installing package

If you are using macOS and you get a permission denied while installing with pip install six, then you could try to execute: pip install --ignore-installed six. check our solution for more details.

Python Index Page 1

macOS Mojave pyenv: Install failed, "zlib not available"

If you are having the error "zlib not available", try to use CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" environment variable before compilation. Check here for more details.

Python Index Page 1

Fast bulk insert with sqlalchemy

SQLAlchemy has some ways to do fask bulk inserts into the database. With this tutorial you will learn how to insert a large number of rows in bulk, using dictionaries or objects.

Python Index Page 1

Elastic search with python

In this tutorial, we are going to use python and elastic search. We are going to cover from scratch how to use elastic search using python. The tutorial could be read by python and elastic search beginners.

Python Index Page 1

How to create ldap users using a python script

In this tutorial, we are going to create a script to create many users on ldap. The input of the script will be a csv file with a list of users. You can later modify the script for your needs, like adding click library to create individual users.

Python Index Page 1

python3 create new empty file

With python3 the best way to touch a file is by using the Path class from pathlib. Once you have an instance of Path (from pathlib import Path) you can use the touch method(): Path('empty_file').touch()

Python Index Page 1

How to use python to access google Spreadsheets

In this tutorial, we are going to use gspread python library to access Google Spreadsheets. We are going to see how to set up credentials on your google account and then how to use the python library to access the spreadsheet. As an example, we will provide a script the calculates the total portfolio value and saves it on the spreadsheet to have a historical data

Python Index Page 1

How to install a dependency with pip from github using setup.py

Steps to install a python dependency from git in the setup.py using dependency_links. Make sure the user is using this format: git+https://github.com/user/repo.git#egg=project_name . Check here for more details.

Python Index Page 1

Python function to generate secure random password

In this short tutorial, we will explain how to write a function to generate a secure random password generator. the function will accept size and chars as parameters. We use SystemRandom since it's more secure and provides more entropy.