Archive for June, 2009

importing as module when a file has a non-identifier name

Friday, June 12th, 2009

I need to reuse a function in a file. The usual way is just to import this file as a module. But what to do if the name is “bad”? The following doesn’t work:


import foo-bar as foo_bar
foo_bar.callme()

After trials and errors, the desired magic found:

(more…)