Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug.': 0.07; 'exception.': 0.07; 'exist,': 0.07; 'raises': 0.07; 'module)': 0.09; 'parsed': 0.09; 'semantics': 0.09; 'subject:2.7': 0.09; 'supported.': 0.09; 'argument': 0.15; 'subject: \n ': 0.15; '0.125),': 0.16; 'ah,': 0.16; 'clear.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'similarly,': 0.16; 'subject:non': 0.16; 'those,': 0.16; 'wrote:': 0.16; 'string': 0.17; 'odd': 0.18; 'pointed': 0.18; 'say,': 0.18; '>>>': 0.20; 'library': 0.20; '2015': 0.20; 'first,': 0.20; 'meant': 0.22; "aren't": 0.22; 'class,': 0.22; 'deployed': 0.22; 'fraction': 0.22; 'mixed': 0.22; 'parse': 0.22; 'parsing': 0.22; 'am,': 0.23; 'third-party': 0.23; 'tim': 0.24; 'header:In-Reply- To:1': 0.24; 'feature': 0.24; 'mon,': 0.24; 'module': 0.25; 'testing': 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'see,': 0.27; 'skip:u 20': 0.28; 'chase': 0.29; 'decimal': 0.29; 'request,': 0.29; 'subject: [': 0.29; 'character': 0.29; 'raise': 0.29; "i'm": 0.30; 'mention': 0.30; 'normally': 0.30; "i'd": 0.31; 'problem': 0.33; 'point,': 0.33; 'smart': 0.33; 'equal': 0.34; 'add': 0.34; 'unicode': 0.35; 'level': 0.35; 'supports': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'being': 0.37; 'expect': 0.37; 'things': 0.38; 'no,': 0.38; 'anything': 0.38; 'someone': 0.38; 'mean': 0.38; 'represent': 0.38; 'does': 0.39; 'received:192': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'easy': 0.60; 'your': 0.60; 'day,': 0.65; '20,': 0.66; "they're": 0.66; 'reserve': 0.67; 'situation': 0.67; 'worth': 0.67; 'hearing': 0.67; '8bit%:21': 0.70; 'jul': 0.72; 'awesome,': 0.84; 'confusing': 0.84; 'difference.': 0.84; 'numerals': 0.84; 'roman': 0.84; 'try.': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JOrGyJ+b c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=JAI3OqB5mnwA:10 a=IkcTkHD0fZMA:10 a=8uR6FKqcAAAA:8 a=1Mb7w-3-1NPN4hLpmYAA:9 a=ghiV7ilr1ZE0PIbE:21 a=2SGknyHz7Wlp1Vtg:21 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 Subject: Re: Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?] To: python-list@python.org References: <7083e494-6192-4acb-aea9-216d858171bc@googlegroups.com> <55ab2b57$0$1664$c3e8da3$5496439d@news.astraweb.com> <20150719075601.779a4edb@bigbox.christie.dr> <20150719145520.5888c9e1@bigbox.christie.dr> From: MRAB Date: Sun, 19 Jul 2015 23:13:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1437344032 news.xs4all.nl 2882 [2001:888:2000:d::a6]:53055 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94167 On 2015-07-19 22:16, Chris Angelico wrote: > On Mon, Jul 20, 2015 at 5:55 AM, Tim Chase > 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 :) > What's the result of, say, float('1e.3')? It raises an exception. So float("2⅛3") should also raise an exception.