Computed attribute names

D

Dale Amon

There are a number of things which I have been used
to doing in other OO languages which I have not yet
figured out how to do in Python, the most important
of which is passing method names as args and inserting
them into method calls. Here are two cases I have been
trying to figure out for a current project.

The first is passing methods to dispatcher methods. In
pseudocode, something like this:

def dispatcher(self,methodname):
self.obj1.methodname()
self.obj2.methodname()

and another case is selecting behavior of an object by
setting a type string, with pseudo code like this:

self.IBM029 = re.compile([^acharset]
self.IBM026 = re.compile([^anothercharset]
self.type = "IBM029"
errs = self.(self.type).findall(aCardImage)

I have yet to find any way to do either, although it appears
I could do some of it using a long and roundabout call string
using __dict__.

What is the Python dialect for this sort of runtime OO?




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFJ3PFRZHES7UL0zXERAiXAAJ0UZyD3589G9hTL/N9A0ect1steAgCaApWJ
HKVHFl3zCrZgSsJEtLU/VJ4=
=B//P
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top