preference tree like in jdk 1.4
Stefan Schwarzer
s.schwarzer at ndh.net
Thu Feb 14 15:00:33 EST 2002
Hello Michael
Michael Chermside wrote:
> Instead of using an empty function, use something designed specifically
> for holding fields: a class!
>
> >>> class Empty:
> pass
> >>> pref = Empty()
> >>> pref.personalData = Empty()
> >>> pref.personalData.firstName = 'John'
> >>> pref.personalData.lastName = 'Cleese'
> >>> pref.windowSettings = Empty()
> >>> pref.windowSettings.windowA = Empty()
> >>> pref.windowSettings.windowA.x = 200
Actually, you use instances of the class to store the values. I think,
you meant that anyway, didn't you? :-)
Sometimes classes are used for such a purpose. However, this may cause
problems if you need more than one "container" (like above). Using
class instances is more common, I assume.
Stefan
More information about the Python-list
mailing list