On Thu, 31 Dec 2009 08:54:57 -0800, Wells wrote:
> Sorry, this is totally basic, but my Google-fu is failing:
>
> I have a variable foo. I want to instantiate a class based on its value-
> how can I do this?
The right way to do it is like this:
>>> class C:
... pass
...
>>> foo = C # assi
Wells schrieb:
Sorry, this is totally basic, but my Google-fu is failing:
I have a variable foo. I want to instantiate a class based on its
value- how can I do this?
class Foo(object):
pass
ze_class = Foo
f = ze_class()
Diez
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Dec 31, 2009 at 8:54 AM, Wells wrote:
> Sorry, this is totally basic, but my Google-fu is failing:
>
> I have a variable foo. I want to instantiate a class based on its
> value- how can I do this?
It sort of depends on where these classes are. If they're in the current
namespace/module,
Wells wrote:
Sorry, this is totally basic, but my Google-fu is failing:
I have a variable foo. I want to instantiate a class based on its
value- how can I do this?
My crystal ball is failing too, could you please elaborate on what
exactly you want to do, some pseudo code with the intended res