Python

New Script Skeleton

#!/usr/bin/python
# vim: set fileencoding=utf-8 :

This is all you need to make an executable python module that defines UTF-8 as it’s default encoding for both vim and python. Download it here.

Packages

... are just directories with an __init__.py file in them:

# vim: set fileencoding=utf-8 :
import package
def f(x):
    pass
__all__ = ['package', 'f']

Ipython

Is “An Enhanced Interactive Python”. Install it with (see Wajig (Package Management)):

wajig install ipython

It has many great features, but these are the best:

  1. Tab-Completion.

  2. “Dynamic object information”

    try import os and then os? for basic info and os?? for the source

  3. type %edit file.py to edit and run file.py

    for this to work, you should set the EDITOR-variable to your favorite editor, e.g.:

    echo 'export EDITOR=/usr/bin/vim' >> $HOME/.bashrc
    source $HOME/.bashrc

Table Of Contents

Previous topic

Networking

Next topic

Buildout

This Page