[wxPython-users] Re: "Pushing" Data to Modules -- SOLVED!

Chris Mellon arkanes at gmail.com
Mon Dec 4 07:35:12 PST 2006


On 12/4/06, Werner F. Bruhin <werner.bruhin at free.fr> wrote:

> Or use strings everywhere and forget to predefine them in your configdata.

I agree with this one - it's especially common for people coming from
C/C++ (I did this too for a long time) to feel the need to define
"constants" for values. That's because you have to use integers as
constants and magic-numbers are a bad idea, for lots of good reasons.
In Python, you can use anything you want as a constant, and I prefer
to just take the name I'd use as a symbolic constant and use it as a
string instead. So instead of defining a PropertyChanged constant and
pubsubbing that, I'd just use the string "PropertyChanged".

The exception case is when I need an enumerated type. For example,
I've got a class shows itself as being in one of 3 states. In that
case, the 3 possible states are constants defined as class attributes
- but they're string values, so if you need to display the state in
the UI, you just print the state - no fancy mappings needed.




More information about the wxpython-users mailing list