Small Troll on notation of variables over time
Jeremy Sanders
jeremy+complangpython at jeremysanders.net
Mon Aug 21 06:36:53 EDT 2006
Hendrik van Rooyen wrote:
> What do you guys think?
You could get something similar using an object, such as
class Hist(object):
def __init__(self):
self.vals = [None]
def __call__(self, index=-1):
return self.vals[index]
def set(self, val):
self.vals.append(val)
a = Hist()
a.set(5)
print a()
a.set('hi there')
print a()
print a(-2)
Which prints
5
hi there
5
--
Jeremy Sanders
http://www.jeremysanders.net/
More information about the Python-list
mailing list