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.

2 comments:

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

    ReplyDelete
  2. 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)

    ReplyDelete