#Python Cheat Sheet
This is a short list of different packages to install to enhace your production in Python
pip is a tool for installing and managing Python packages
apt-get install python-pip python-dev build-essential
virtualenv is a tool to create isolated Python environments. There is 2 ways to install it:
With apt if you have an Ubuntu or Debian system
apt-get install python-virtualenv
With pip if you want to ignore your system package tool
pip install virutalenv
If you use pip to install globally virtualenv with just add sudo before
you can use glob
import glob
import os
os.chdir("/mydir")
for files in glob.glob("*.txt"):
print files
or simple os.listdir
import os
os.chdir("/mydir")
for files in os.listdir("."):
if files.endswith(".txt"):
print files
or if you want to traverse directory
import os
for r,d,f in os.walk("/mydir"):
for files in f:
if files.endswith(".txt"):
print os.path.join(r,files)
To make the libraries available, you have to add this package first:
apt-get install python-mysqldb