HGPA

python -- Notes on the Python programming Language

Implementations of Fundamental Types

List:

Tuple:

Set:

Dictionary:

Built-in functions

Use range(a) for loops. Note that range(a,b) returns an empty array if a and b are equal.

slice(start, stop) but use a[start:stop] instead

Numbers:

String:

Iterables:

imports

Concurrency

TIPS

Functions can return multiple values:

def return_both(a,b):
  return a,b
x,y = return_both(1,2)

You can put multiple statements on one line by using a semi-colon, e.g. i += 1; j += 1 but this is discouraged. Perhaps only do this on a whiteboard or doc to save space.

Get an object's reference count: sys.getrefcount(obj)

pip

pip is the python package manager

setuptools is the fundamental pip dependency

virtualenv

virtualenv creates a virtual environment for each program with:

Installation:

Virtual environments are not saved in you application folder. They are located in ~/.virtualenvs/name_of_env When you pip install a package that contains global binary then it is isntall in ~/.virtualenvs/name_of_env/bin

REFERENCES

A Byte of Python. Swaroop Chitlur.

A non-magical introduction to Pip and Virtualenv for Python beginners. Jamie Matthews. 2013-04-18.

Design and History FAQ. Python Documentation.

The Mighty Dictionary. Brandon Craig Rhodes. PyCon 2010. An optimized explanation of Python's Dictionary implementation using a hash table.

Filename: python.md (Edit)
Modified: 2017-02-06 (212c05bcc2d1324cb4fd072c148a09784b4a219c)
Created: 2016-11-01 (208574db84e0e0294c29fb0f96067ef4a3a66416)