[Python-Dev] ++x oddnes (original) (raw)

Fredrik Lundh fredrik@pythonware.com
Mon, 13 Aug 2001 16:12:15 +0200


skip wrote:

How? ++x compiles to

LOADFAST x UNARYPOSITIVE UNARYPOSITIVE I don't see any incrementing going on...

try this:

class StupidCounter: count = 0 def pos(self): self.count = self.count + 1 return 0 # ignore extra pos calls def int(self): return self.count def repr(self): return repr(self.count)

c = StupidCounter() print c ++c print c