preference tree like in jdk 1.4

Tripp Scott tripps81 at yahoo.com
Thu Feb 14 11:52:16 EST 2002


i was looking into the preferences api in the jdk 1.4 
documentation [1] and wonder how this could be done as simple as 
possible in python. in short, preferences is a tree branch of 
options you can store and load, just like ini files or registry settings.

i was thinking of an empty function:

  def empty(): pass

and then use it to build complex tree of preferences:

  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
  # and so on...

to store or load this pref object, just use the pickle mechanism.

my question is, is there a simpler, more beautiful, elegant way?

t

[1] 
http://developer.java.sun.com/developer/technicalArticles/releases/preferences/





More information about the Python-list mailing list