Best way to dynamically get an attribute from a module from within the same module

Jeremy Sanders jeremy+complangpython at jeremysanders.net
Mon Dec 1 06:53:03 EST 2008


Rafe wrote:

> I guess, in the end, I'd use getattr() because it feels more pythonic,
> and more basic. I got pretty deep in to learning python before I had
> to learn what the globals() dict could do for me.

Why not store your individual classes inside another class or keep them in a
dict? That would be clearer, would not mess around with global namespace,
and more pythonic IMHO.

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/



More information about the Python-list mailing list