Computed attribute names

Discussion in 'Python' started by Dale Amon, Apr 8, 2009.

  1. Dale Amon

    Dale Amon Guest

    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-----
     
    Dale Amon, Apr 8, 2009
    #1
    1. Advertising

  2. On Wed, 8 Apr 2009 19:47:46 +0100, Dale Amon <> wrote:
    [snip]
    > self.IBM029 = re.compile([^acharset]
    > self.IBM026 = re.compile([^anothercharset]


    Whoa! Thanks for the trip down memory lane. And a cheery
    IEFBR14 to you, too.

    --
    To email me, substitute nowhere->spamcop, invalid->net.
     
    Peter Pearson, Apr 10, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Du

    Computed columns in datagrid

    Raymond Du, Dec 1, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,620
    Joe Fallon
    Dec 2, 2004
  2. John Dalberg
    Replies:
    1
    Views:
    438
    Bruce Barker
    Feb 3, 2006
  3. Replies:
    2
    Views:
    902
    Adam Maass
    May 24, 2005
  4. Pascal Steiss
    Replies:
    1
    Views:
    3,479
    Toby Inkster
    Mar 19, 2005
  5. Carl
    Replies:
    0
    Views:
    540
Loading...

Share This Page