Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94164

Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?]

References (4 earlier) <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> <CAPTjJmoV1MV4Fyr39iYL0s0o_sXYQvZmkgrLMcDA1UfsvyFf8w@mail.gmail.com> <20150719145520.5888c9e1@bigbox.christie.dr>
Date 2015-07-20 07:16 +1000
Subject Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?]
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.744.1437340623.3674.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jul 20, 2015 at 5:55 AM, Tim Chase
<python.list@tim.thechases.com> wrote:
> On 2015-07-20 04:07, Chris Angelico wrote:
>> The int() and float() functions accept, if I'm not mistaken,
>> anything with Unicode category "Nd" (Number, decimal digit). In
>> your examples, the fraction (U+215B) is No, and the Roman numerals
>> (U+2168, U+2182) are Nl, so they're not supported. Adding support
>> for these forms might be accepted as a feature request, but it's
>> not a bug.
>
> Ah, that makes sense.  Some simple testing (thanks, unicodedata
> module) supports your conjecture.
>
> It's not a particularly big deal so not really worth the brain-cycles
> to add support for them.  Just upon hearing "Python's int() does
> smart things with Unicode characters", those were some of my first
> characters to try.  The failure struck me as odd until you explained
> the simple difference.

The other part of the problem is: What should float("2⅛3") be? Should
it be equal to 21.0/83.0? Should the first part be parsed as a classic
mixed number (2 + 1/8), and then what should the 3 mean? While it's
easy to see what an individual character should represent (just check
unicodedata.numeric(ch) - for ⅛ it's 0.125), the true meaning of a
string of such characters is less than clear. Similarly, Roman
numerals aren't meant to be used after the decimal point, so "Ⅸ.Ⅴ"
does not normally mean nine and a half... not to mention the confusing
situation that "ⅠⅤ" would naively parse as 15 but "Ⅳ" is definitely 4.
Since these kinds of complexities exist, it's safest to reserve this
level of parsing for a special-purpose function. If someone can come
up with a really strong argument for the float() and int()
constructors interpreting these, I'd expect to see it deployed as a
third-party module first, before being pointed out as "see, you can
use float() for all these, but if you want to use those, you should
use Float() instead". (Incidentally, I fully expect to see, some day,
pytz.localize() semantics brought into the standard library
datetime.datetime class, for precisely this reason.)

Unicode is awesome, but it's not a panacea :)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-18 19:33 -0700
  Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-18 19:49 -0700
  Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-18 20:52 -0700
    Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-18 21:18 -0700
    Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-19 14:45 +1000
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-19 15:06 +1000
        Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-19 10:16 +0300
          Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-19 00:32 -0700
            Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-19 10:44 +0300
            Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Terry Reedy <tjreedy@udel.edu> - 2015-07-19 19:13 -0400
              Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-19 19:02 -0700
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Anuradha Laxminarayan <lanuradha@gmail.com> - 2015-07-18 23:25 -0700
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Terry Reedy <tjreedy@udel.edu> - 2015-07-19 04:26 -0400
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Tim Chase <python.list@tim.thechases.com> - 2015-07-19 07:56 -0500
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-20 04:07 +1000
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Tim Chase <python.list@tim.thechases.com> - 2015-07-19 14:55 -0500
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-20 07:16 +1000
        Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] wxjmfauth@gmail.com - 2015-07-20 00:43 -0700
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] MRAB <python@mrabarnett.plus.com> - 2015-07-19 23:13 +0100
      Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-20 20:30 -0700
        Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-21 13:43 +1000
          Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-20 23:11 -0700
        Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-21 10:10 +0200
          Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 12:10 +0300
            Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-21 19:18 +1000
              Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 13:13 +0300
            Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-21 11:34 +0100
            Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-21 20:39 +1000
              Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-21 13:54 +0300
                Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-08-09 00:27 +0300
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-08-09 09:29 -0700
              Re:  Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 06:34 -0700
                OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-23 02:58 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-22 19:17 +0200
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 10:49 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-22 20:14 +0200
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-22 21:59 +0100
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve@pearwood.info> - 2015-07-23 03:21 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-22 21:44 -0400
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-23 12:00 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-22 10:48 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 10:51 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:14 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-22 11:09 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-23 15:41 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-23 23:59 +0300
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 07:03 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-24 00:29 +0300
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-23 22:50 +0100
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-23 23:52 +0200
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-24 00:59 +0300
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 08:02 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Chris Angelico <rosuav@gmail.com> - 2015-07-24 08:00 +1000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] MRAB <python@mrabarnett.plus.com> - 2015-07-23 23:01 +0100
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Laura Creighton <lac@openend.se> - 2015-07-24 00:19 +0200
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-23 23:56 +0100
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Grant Edwards <invalid@invalid.invalid> - 2015-07-24 00:07 +0000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-23 18:40 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-23 19:03 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-23 20:16 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Grant Edwards <invalid@invalid.invalid> - 2015-07-24 14:13 +0000
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Paul Rubin <no.email@nospam.invalid> - 2015-07-24 08:45 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-24 16:58 +0100
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 22:15 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security   2.7 bugs be fixed?] Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-07-23 18:57 +1200
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 02:12 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Rustom Mody <rustompmody@gmail.com> - 2015-07-23 05:52 -0700
                Re: OT Re: Math-embarrassment results in CS [was: Should non-security 2.7 bugs be fixed?] Marko Rauhamaa <marko@pacujo.net> - 2015-07-23 11:24 +0300
        Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-07-21 18:57 +1000
    Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-19 02:44 -0400
    Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-19 05:11 -0400
      Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-19 07:30 -0700
    Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-19 15:00 +0100
  Re: Should non-security 2.7 bugs be fixed? Steven D'Aprano <steve@pearwood.info> - 2015-07-19 14:45 +1000
    Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-19 18:20 -0700
      Re: Should non-security 2.7 bugs be fixed? Steven D'Aprano <steve@pearwood.info> - 2015-07-20 13:05 +1000
        Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-19 20:41 -0700
    Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-20 02:46 +0100
      Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-19 19:16 -0700
        Re: Should non-security 2.7 bugs be fixed? Chris Angelico <rosuav@gmail.com> - 2015-07-20 12:59 +1000
        Re: Should non-security 2.7 bugs be fixed? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-20 11:59 +0100
        Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-20 20:04 -0700
          Re: Should non-security 2.7 bugs be fixed? Rustom Mody <rustompmody@gmail.com> - 2015-07-20 20:15 -0700
            Re: Should non-security 2.7 bugs be fixed? Chris Angelico <rosuav@gmail.com> - 2015-07-21 13:33 +1000
            Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-21 00:45 -0400
          Re: Should non-security 2.7 bugs be fixed? breamoreboy@gmail.com - 2015-07-21 14:22 -0700
            Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-21 19:07 -0700
              Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-22 02:51 -0400
                Re: Should non-security 2.7 bugs be fixed? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-22 16:37 -0700
    Re: Should non-security 2.7 bugs be fixed? Terry Reedy <tjreedy@udel.edu> - 2015-07-20 02:25 -0400
    Re: Should non-security 2.7 bugs be fixed? dieter <dieter@handshake.de> - 2015-07-20 08:58 +0200
    Re: Should non-security 2.7 bugs be fixed? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-07-20 00:13 -0700

csiph-web