with the difference that you 1) pass the module name as a string, and 2) explicitly assign it to a variable in your current namespace.

+

+

== Content of objects ==

+

Finding what's in an object

Finding what's in an object

>>> dir(obj)

>>> dir(obj)

+

+

== Copying objects ==

+

+

Regular:

+

obj2 = obj1

+

+

Complete:

+

obj2 = copy.deepcopy(obj1)

+

+

== Key, Values of dicts ==

+

+

ah iteritems() ...

+

+

>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}

+

>>> for k, v in knights.iteritems():

+

... print k, v

+

+

== Any kind of garbage ==

+

+

.strip(string.whitespace + string.punctuation)

+

+

== Glob me baby! File completion in a snap ==

+

+

self.list = glob.glob("*.db")

+

+

== Getting content AND index from lists ==

+

+

for index,line in enumerate(content):

+

...

+

+

= Debugging =

+

+

See http://pythonconquerstheuniverse.wordpress.com/category/the-python-debugger/

+

+

import pdb

+

pdb.set_trace()

+

= Editor tricks =

= Editor tricks =

Line 12:

Line 65:

See http://python.about.com/b/2007/09/24/emacs-tips-for-python-programmers.htm

See http://python.about.com/b/2007/09/24/emacs-tips-for-python-programmers.htm

-

# C-c <: Shift the region to the left

+

* C-c <: Shift the region to the left

-

# C-c >: Shift the region to the right

+

* C-c >: Shift the region to the right

+

+

= HOW TO =

+

+

== Modules & Extensions: distutils ==

+

* http://docs.python.org/extending/building.html

+

* http://docs.python.org/distutils/

+

+

One mention, sometime you get this error message when building your extension under Mac OS X:

+

/usr/bin/ld: can't locate file for: -lnameofmylib

+

+

This seems to be a weird problem with Mac OS X where even if the library (here a dynamic library ending with .dylib) is in /usr/lib, it won't be "seen" by the ld linker. To mitigate this problem, create a link in /usr/local/lib/ to the /usr/lib/XXXX.dylib library and add the path in the setup.py file.

HOW TO

Modules & Extensions: distutils

One mention, sometime you get this error message when building your extension under Mac OS X:

/usr/bin/ld: can't locate file for: -lnameofmylib

This seems to be a weird problem with Mac OS X where even if the library (here a dynamic library ending with .dylib) is in /usr/lib, it won't be "seen" by the ld linker. To mitigate this problem, create a link in /usr/local/lib/ to the /usr/lib/XXXX.dylib library and add the path in the setup.py file.