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/2006-November/070020.html below:

[Python-Dev] infinities

[Python-Dev] infinities [Python-Dev] infinitiestomer filiba tomerfiliba at gmail.com
Sun Nov 26 16:40:52 CET 2006
i found several places in my code where i use positive infinity
(posinf) for various things, i.e.,

    def readline(self, limit = -1):
        if limit < 0:
            limit = 1e10000 # posinf
        chars = []
        while limit > 0:
            ch = self.read(1)
            chars.append(ch)
            if not ch or ch == "\n":
                break
            limit -= 1
        return "".join(chars)

i like the concept, but i hate the "1e10000" stuff... why not add
posint, neginf, and nan to the float type? i find it much more readable as:

    if limit < 0:
        limit = float.posinf

posinf, neginf and nan are singletons, so there's no problem with
adding as members to the type.


-tomer
More information about the Python-Dev mailing list

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