make a class instance from a string ?

Terry Hancock hancock at anansispaceworks.com
Thu Feb 23 12:35:23 EST 2006


On 23 Feb 2006 05:22:25 -0800
"Luke Plant" <luke.plant at gmail.com> wrote:
> In Python, classes are first class objects, so normally
> you would pass the class itself around, rather than use
> the names of classes.  Of course that might not be
> practical or applicable in your situation.

It is in fact, a particular source of annoyance when the
object is meant to be serialized to disk with pickle or
the like, and especially when it is an extension object.

A good idiom for "look me up in the source code after you
unpack me" is required. I think some things like ZODB
will already do that for you, but it seems basic enough
that there ought to be a general approved method of doing
that in Python -- you know, "one obvious way".

-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com



More information about the Python-list mailing list