Dec. 22nd, 2009

zwol: ((mad) science)

In Python >= 2.5, if you need to do

    from . import module

but you don't know the name of module until runtime, this is how you do it:

    mod = getattr(__import__('', globals(), locals(),
                             [name], 1), name)

(This is going on my big list of things I will change when I am the BDFL.)

April 2017

S M T W T F S
      1
2345678
9101112131415
16171819 202122
23242526272829
30      

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 6th, 2026 09:04 pm
Powered by Dreamwidth Studios