[Python-Dev] infinities (original) (raw)
Bob Ippolito bob at redivi.com
Sun Nov 26 16:52:24 CET 2006
- Previous message: [Python-Dev] infinities
- Next message: [Python-Dev] infinities
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/26/06, tomer filiba <tomerfiliba at gmail.com> wrote:
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.
sys.maxint makes more sense there. Or you could change it to "while limit != 0" and set it to -1 (though I probably wouldn't actually do that)...
There is already a PEP 754 for float constants, which is implemented in the fpconst module (see CheeseShop). It's not (yet) part of the stdlib though.
-bob
- Previous message: [Python-Dev] infinities
- Next message: [Python-Dev] infinities
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]