two new wrinkles to the general class!

syd syd.diamond at gmail.com
Thu Nov 4 11:22:05 EST 2004


>     new_copy = self.__class__()

Awesome!  I didn't know I could call it like that... thanks, Jeff.

>     method = Collection.get_foo('bar')
>     method()

I suppose I knew that, but I wasn't thinking.  I can do something like
(for nation as a component of library):

(criteria='foo' or 'bar' or whatever... grabbed from __getattr__)
isMethodString='is'+criteria
isMethod=getattr(library,isMethodString)

then the criteria for inclusion becomes when isMethod()==True

----------------------------------------------

One final question that I can't seem to get, but I know I should be
able to do:

Given a Library class with possible component class types Nation_A,
Nation_B, and so forth where type(Nation_A)<>type(Nation_B).  If I had
the string 'Nation_B', how could I get an empty class Nation_B?

ie,
dir()=['Library','Nation_A','Nation_B',...]
desiredEmptyClassString=dir[2]
desiredEmptyClass=getEmptyClassFromString(desiredEmptyClassString)
Does a "getEmptyClassFromString" method exist?




More information about the Python-list mailing list