[Tutor] Flat is better than Nested
Ryan Strunk
ryan.strunk at gmail.com
Fri Sep 9 04:39:47 CEST 2011
Hello everyone,
I am still learning to program by writing this boxing game. I'm running into
a problem with how to organize data. My current setup looks something like
this:
"""This feels incredibly disgusting to me."""
self.behaviors = {
'offensive_combos': {
'combo1': {
1: { #time in seconds
'punch': {
'speed': 2,
'strength': 4,
'side': 'left'}
}
1.5: { #time in seconds
'punch': {
'speed': 4,
'strength': 8,
'side': 'right'}
}
}
}
}
By the time I write this all into a file, the end user will never even know
this crazy hierarchy exists, but I will, and I don't like it. Do I just need
to get over it and realize that sometimes nested is necessary, or is there a
better way I might consider?
Thanks for any help you can provide.
Best,
Ryan
More information about the Tutor
mailing list