Re: instantiate a class with a variable

2006-03-28 Thread John
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 >

Re: instantiate a class with a variable

2006-03-28 Thread bruno at modulix
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 &#x

Re: instantiate a class with a variable

2006-03-27 Thread Ben Finney
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

Re: instantiate a class with a variable

2006-03-27 Thread Cameron Laird
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

Re: instantiate a class with a variable

2006-03-27 Thread Ben Finney
"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:

instantiate a class with a variable

2006-03-27 Thread John
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