Scott write -
Arthur wrote:
On Sat, 2004-12-18 at 15:56 -0800, Scott David Daniels wrote:
Arthur wrote:
... to get my bi-directional communication, all I need to do is setattr(Display,"control_panel",self) in the __init__ of the Tk ControlPanel... My first ever use of setattr. Knew it was there for something ;)
Hmmm.... Outside of playing with setattr, why not use: Display.control_panel = self ... On the other hand I am sometimes forced into some ingenuity in the use of what I *do* know, and feel I sometimes end up with something that avoids being more occult than necessary - whereas someone more comfortable at those levels may have immediately jumped there for a solution.
OK, I was doing two things, (1) suggesting another simpler (more readable) form, and (2) honestly asking whether this was, in fact, a reasonable substitution, or whether there was a consideration that I hadn't understood.
I appreciated your comment, and I hope you understand that I was poking fun at myself, because: 1. Your substation is simpler and more readable. 2. I see no reason it doesn't work exactly as well. 3 My post was patting myself on the back for finding a simple solution to my problem, when there was an obvious further simplification staring me in the face, and I was overlooking.
I always wind up with crappy code on my way to programs I like. Writing code, like writing English, is a process of inspiration and rework. I like the process in code, and hate the same process for writing English. Probably for two reasons.
PyGeo is on its eightieth round of refactoring. In my case the issue is three fold 1. the normal issues involved in finding one's way to simple, maintainable, readable and efficient code. 2. I am learning as I go - so I can have code refactored down to nearly its best form, based on what I know and find that new possibility open up, when I know more. 3. Python's evolution. Python2.3, e.g., may well present opportunities to simplifier the code that was not present in Python2.2. At my normal billing rates, PyGeo is a $1m project. ;) Art