Exemple #1
0
########################################
#

from treedict import TreeDict
t = TreeDict()

# Attribute-style and dict-style setting are interchangable.
t["run.action"] = True
t.run.time_of_day = "Morning"

# Intermediate branches are implicitly created
t.programmer.habits.morning = ["drink coffee", "Read xkcd"]

# read_xkcd is implicitly created here, but isn't really part of the
# tree until later
t.action = t.read_xkcd

# This attaches the dangling branch read_xkcd above
t.read_xkcd.description = "Go to www.xkcd.com and read."
t.read_xkcd.expected_time = "5 minutes."

########################################
# Dict example

from treedict import TreeDict
d = {"x": 1, "y": 2, "a.b.x": 3, "a.b.c.y": 4}
t = TreeDict()
t.update(d)
print t.makeReport()

from treedict import TreeDict
########################################
#

from treedict import TreeDict
t = TreeDict()

# Attribute-style and dict-style setting are interchangable.
t["run.action"]             = True
t.run.time_of_day           = "Morning"

# Intermediate branches are implicitly created
t.programmer.habits.morning = ["drink coffee", "Read xkcd"]

# read_xkcd is implicitly created here, but isn't really part of the
# tree until later
t.action = t.read_xkcd

# This attaches the dangling branch read_xkcd above
t.read_xkcd.description     = "Go to www.xkcd.com and read."
t.read_xkcd.expected_time   = "5 minutes."

########################################
# Dict example

from treedict import TreeDict
d = {"x" : 1, "y" : 2, "a.b.x" : 3, "a.b.c.y" : 4}
t = TreeDict()
t.update(d)
print t.makeReport()

from treedict import TreeDict