misleading prefix ++
Edward Elliott
nobody at 127.0.0.1
Sat May 20 22:16:59 EDT 2006
Peter Otten wrote:
>>>> class Int(object):
[snip]
> ... def __pos__(self):
> ... if self.half:
> ... self.value += 1
> ... self.half = not self.half
> ... return self
[snip]
>>>> i = Int()
which leads us to:
>>>> i
> 0
>>>> +i
> 0
>>>> +i
> 1
>>>> +i
> 1
>>>> +i
> 2
Now that is absolutely lovely. Looks like it's time to join the ranks of
Perl and C with an Obfuscated Python Contest. ;)
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
More information about the Python-list
mailing list