Here’s the code: http://paste.pocoo.org/show/238093/
My main questions right now are:
-
Is Line 37 mainly the gist of this program? And does it simply calculate this once and then print the result? Ex:
self.start + key*self.stepwithstart=1, key=4, step=2[prints 9] -
where does the variable ‘value’ actually come into play here? Line 39.
-
Not worried about the “Exceptions” part of the program. I pretty much understand what it’s doing.
-
Lastly, and you really don’t have to answer this one as it’s probably better as another question “down the road” but I really do not see how
__getitem__,__setitem__…etc…you still have to write in your own code to “make it do stuff”. 🙂 I’m just not getting what’s so “special” about these special methods.
return self.changed.get(key, self.start + key*self.step)—dict.getlets you provide a default to return if a key is missing.yourthing[foo]oryourthing[foo] = bar. You see the first going on here; the second is what happens if someone doess[5] = 100— the 100 ends up as thevalueof a__setitem__call.