Friday, May 30, 2008

Ouroboros

Circular dependencies will break your Python code!


Ouroboros

Given some module A that depends upon module B (ie, import B), and given a module B which depends upon module A, you'll get this rather cryptic error message:

ImportError: cannot import name A

This works at any remove, of course -- the circle could stretch through 1,000 modules, but once you forge that loop, you're toast.

The solution is to refactor your code to put routine from A needed by B into a separate module C that depends upon neither.

Wednesday, May 28, 2008

Leopard emacs is broken...

Which means that GNUplot is broken under Leopard, and with it, scipy.

Fortunately, there's a solution:


sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.backup
sudo /usr/libexec/dumpemacs -d
emacs --version
emacs


It's quite beyond me why the emacs shipping w/ Leopard is broken out of the box, but can be repaired via the dumpemacs command, but there it is.