Infinity syntax. Re: Bug in string.find; was...
Kay Schluehr
kay.schluehr at gmx.net
Wed Aug 31 14:25:51 EDT 2005
Bengt Richter wrote:
> >>>> range(9)[4:-!0:-1] == range(5)
> >True
> Interesting, but wouldn't that last line be
> >>> range(9)[4:-!0:-1] == range(5)[::-1]
Ups. Yes of course.
> >Life can be simpler with unbound limits.
> Hm, is "!0" a di-graph symbol for infinity?
> What if we get full unicode on our screens? Should
> it be rendered with unichr(0x221e) ? And how should
> symbols be keyed in? Is there a standard mnemonic
> way of using an ascii keyboard, something like typing
> Japanese hiragana in some word processing programs?
You can ask questions ;-)
> I'm not sure about '!' since it already has some semantic
> ties to negation and factorial and execution (not to mention
> exclamation ;-) If !0 means infinity, what does !2 mean?
>
> Just rambling ... ;-)
I'm not shure too. Probably Inf as a keyword is a much better choice.
The only std-library module I found that used Inf was Decimal where Inf
has the same meaning. Inf is quick to write ( just one more character
than !0 ) and easy to parse for human readers. Rewriting the above
statements/expressions leads to:
>>> Inf
Inf
>>> Inf+1
Inf
>>> Inf>n # if n is int
True
>>> Inf/Inf
Traceback (...)
...
UndefinedValue
>>> Inf - Inf
Traceback (...)
...
UndefinedValue
>>> -Inf
-Inf
>>> range(9)[4:Inf] == range(9)[4:]
True
>>> range(9)[4:-Inf:-1] == range(5)[::-1]
True
IMO it's still consice.
Kay
More information about the Python-list
mailing list