A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-August/016977.html below:

[Python-Dev] ++x oddnes

[Python-Dev] ++x oddnes [Python-Dev] ++x oddnesFredrik Lundh fredrik@pythonware.com
Mon, 13 Aug 2001 16:12:15 +0200
skip wrote:
> How?  ++x compiles to
>
>          LOAD_FAST         x
>          UNARY_POSITIVE
>          UNARY_POSITIVE
>
> 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

</F>





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4