Thanks for the help, this was exactly what I needed. Working Great
bruno at modulix wrote:
> John wrote:
> > Hi, is it possible to instantiate a class with a variable.
> >
> > example
> >
> > class foo:
> > def method(self):
> > pass
>
John wrote:
> Hi, is it possible to instantiate a class with a variable.
>
> example
>
> class foo:
> def method(self):
> pass
>
> x='foo'
>
> Can I use variable x value to create an instance of my class?
You got examples using string
Ben Finney <[EMAIL PROTECTED]> writes:
> >>> class Foo:
> ... pass
> ...
> >>> foo_name = 'foo'
Dang. As Cameron Laird points out, this should be
>>> foo_name = 'Foo'
each time.
Moral of the story: if the example already works, and then you cut and
paste into the messag
In article <[EMAIL PROTECTED]>,
Ben Finney <[EMAIL PROTECTED]> wrote:
>"John" <[EMAIL PROTECTED]> writes:
>> class foo:
>> def method(self):
>> pass
>>
>> x='foo'
>>
>> Can I use variable x value to create an instance of my class?
>
>You seem to be asking "is it possible to call an obj
"John" <[EMAIL PROTECTED]> writes:
> class foo:
> def method(self):
> pass
>
> x='foo'
>
> Can I use variable x value to create an instance of my class?
You seem to be asking "is it possible to call an object whose name is
stored in a string".
The answer is yes::
>>> class Foo:
Hi, is it possible to instantiate a class with a variable.
example
class foo:
def method(self):
pass
x='foo'
Can I use variable x value to create an instance of my class?
Thanks, John
--
http://mail.python.org/mailman/listinfo/python-list