Re: How do I call anonymous classes from imported modules?

2007-08-20 Thread JoeSox
On 8/19/07, James Stroud <[EMAIL PROTECTED]> wrote: > This was the poor design I was hinting to. do_foobar is type-checking > for ticker. "Casting" as you might think of it does not exist in python. > Creating new objects based on the values of existing objects (lets call > it "conversion" for lack

Re: How do I call anonymous classes from imported modules?

2007-08-19 Thread James Stroud
JoeSox wrote: > On 8/19/07, James Stroud <[EMAIL PROTECTED]> wrote: >> Quick and dirty (you could also use a try: except:): >> >> f = __import__(module_name) >> for anobj in f.__dict__.values(): >> if hasattr(anobj, 'do_foobar'): >> anobj.do_foobar() >> >> Note that this does not test whether

Re: How do I call anonymous classes from imported modules?

2007-08-19 Thread JoeSox
On 8/19/07, James Stroud <[EMAIL PROTECTED]> wrote: > Quick and dirty (you could also use a try: except:): > > f = __import__(module_name) > for anobj in f.__dict__.values(): > if hasattr(anobj, 'do_foobar'): > anobj.do_foobar() > > Note that this does not test whether anobj is a class as thi

Re: How do I call anonymous classes from imported modules?

2007-08-19 Thread James Stroud
JoeSox wrote: > I am importing 3rd party modules via a plugin script. I wish to > iterate thru the modules and call a common method like .do_foobar() or > something with all the imports. > But I can't figure out how to do something like below without knowing > the class name before hand. Is there

How do I call anonymous classes from imported modules?

2007-08-19 Thread JoeSox
I am importing 3rd party modules via a plugin script. I wish to iterate thru the modules and call a common method like .do_foobar() or something with all the imports. But I can't figure out how to do something like below without knowing the class name before hand. Is there a builtin that helps cal

Re: Anonymous Classes

2007-07-12 Thread Lachlan Gunn
Thanks for your help. After trying your suggestion for a while, I eventually realised that SQLObject was doing something funny in its metaclass that was causing the issue, which I got around by mangling the class names with a counter. -- http://mail.python.org/mailman/listinfo/python-list

Re: Anonymous Classes

2007-07-12 Thread Bruno Desthuilliers
Lachlan Gunn a écrit : > Hello. > > I have a library (SQLObject) that stores data as class variables. I would > like to set a class variable in a certain context, specific to a certain > instance of an object. This would require some sort of anonymous class. I > have attempted to use the follow

Anonymous Classes

2007-07-12 Thread Lachlan Gunn
Hello. I have a library (SQLObject) that stores data as class variables. I would like to set a class variable in a certain context, specific to a certain instance of an object. This would require some sort of anonymous class. I have attempted to use the following code to set the connection stri