pythonaro.com

Pythonaro blog

01 June 2009

note to self

When you start writing hacks like this:

for attr in ['Something1','someThing2'...'SomeThing215']:
    self.__dict__[attr.lower()+'Widget'].do_something(someValue)
    self.__dict__[attr.lower()+'Widget'].set_parameter(someparameter)
... it's probably time for a subclass.

Labels: ,

posted by GiacomoL @ 9:08 AM  

2 Comments:

  • At 1/6/09 09:30, Blogger Giulio Piancastelli said…

    ...and it's probably time to repent as well. How did you get trapped into that mess in the first place? :-D

     
  • At 1/6/09 10:48, Blogger GiacomoL said…

    When you have to manage 20+ textual fields in one screen, you take all the shortcuts you can find :)

    Note that I only reduced the hackery, but it's still there and I honestly can't find a better way; it's now something like this:
    for item in mysequence: self.__dict__[item+'Entry'] = NewClass(item)

     

Post a Comment

  |  

Links to this post:

Create a Link

<< Home