[Python-ideas] float('∞')=float('inf')

Joshua Landau joshua at landau.ws
Fri Jul 12 20:07:07 CEST 2013


On 12 July 2013 18:21, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
>
> On Fri, Jul 12, 2013 at 12:15 PM, Joshua Landau <joshua at landau.ws> wrote:
>>
>> > I would actually support the idea for float() to accept whatever
>> > unicodedata.numeric() accepts.
>>
>> It doesn't free us from tons of special cases. We already have people
>> arguing over whether 3½ is the traditional 3.5 or whether it's 1.5.
>> We'll need tons of new parsing rules. I'm not convinced, in other
>> words.
>
>
> I should have explained my idea in more detail.  I am not suggesting that
> float('3½') should work.  I wrote: "float() to accept whatever
> unicodedata.numeric() accepts" and
>
>>>> unicodedata.numeric('3½')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: need a single Unicode character as parameter
>
> Since python does not have a character type, I think it is acceptable for
> single-character strings to be special.

For reference, you want to define these:

៲: 2      ᛰ: 19     𝍱: 90     ៶: 6      ⓴: 20     ൵: 3/4    ⅞: 7/8    ፹:
80     ⑿: 12     ⅽ: 100    𐅱: 1000   𑁜: 20     Ⅵ: 6      𐹫: 30     仨: 3


𝍩: 10     ⑯: 16     ⓬: 12     Ⅽ: 100    ㉓: 23     〩: 9      ⅕: 1/5    ㉛:
31     ௱: 100    ፵: 40     𐡟: 10000  ⅝: 5/8    什: 10     十: 10     𒑇: 9


𐅅: 500    ㉋: 40     𒑏: 1      𐅍: 1000   零: 0      𐩆: 100    ༱: 15/2
𒐷: 3      𐄓: 40     ㊸: 43     𒐿: 4      ¼: 1/4    𐄛: 300    ㈣: 4
 ⅶ: 7

𐌡: 5      〧: 7      𐄥: 4000   幺: 1      廾: 9      𐩾: 50     Ⅳ: 4
 𒐯: 3      𐄭: 30000  ㆒: 1      玖: 9      𒐗: 3      ⒔: 13     𐄕: 60
𠬙: 3

𒐟: 2      𐄝: 500    ↂ: 10000  七: 7      ㊀: 1      Ⅱ: 2      〇: 0      ⒄:
17     𣬛: 3      𐆊: 0      ㊈: 9      ᛯ: 18     𒐏: 4      𐄍: 7      𐅲:
5000

𐹰: 80     ៱: 1      ୶: 1/8    ৵: 1/8    ⅺ: 11     陸: 6      ៹: 9      𐭾:
100    ꠰: 1/4    ౼: 1      什: 10     Ⅲ: 3      𝍦: 7      𑁤: 100    Ⅺ: 11


ꛫ: 6      𝍮: 60     ꛨ: 3      ⑬: 13     ⅒: 1/10   ⒂: 15     Ⅹ: 10     𒐴:
1      𒑔: 5      ⅚: 5/6    四: 4      ㉘: 28     𐡞: 1000   𐭞: 100    𒑜:
5/6

𐡜: 20     𐅂: 1      叁: 3      𒑄: 8      𐅊: 50     ⒆: 19     ㉈: 10
六: 6      𐅳: 5      〸: 10     𒑌: 4      𐄲: 80000  ㊳: 38     ꠴: 1/8    ㊻:
46

𒐅: 7      𒐼: 4      ㊿: 50     𐄢: 1000   ㈠: 1      ⅑: 1/9    〤: 4
 𐄋: 5      𠤪: 1      ㈨: 9      ⑾: 11     ༮: 9/2    萬: 10000  𐄒: 30
⅙: 1/6

𒐉: 4      𐄖: 70     ⒗: 16     𒐔: 9      ㆕: 4      𐄚: 200    𐅕: 10000
 ୳: 1/2    𒐜: 8      ൱: 100    ㊃: 4      一: 1      漆: 7      ⒇: 20     𒐄:
6

ↅ: 6      𐄊: 4      ➉: 10     弎: 3      𒐌: 7      ⓲: 18     ፳: 20     ௰:
10     𐭙: 2      零: 0      𐅷: 2/3    ৴: 1/16   ፻: 100    ៸: 8      𐹹:
800

拾: 10     ⅿ: 1000   𑁟: 50     𠃢: 4      𐄪: 9000   壱: 1      ꛦ: 1      Ⅷ:
8      𑁥: 1000   𝍫: 30     𐹩: 10     ꛮ: 9      Ⅿ: 1000   ⑭: 14     ㉑: 21


𐅗: 10     𒑕: 5      ㉜: 32     𐭛: 4      ㉙: 29     Ⅻ: 12     ⅟: 1
 𐡝: 100    千: 1000   𐍁: 90     𐅇: 50000  𒑅: 8      ㉉: 20     𐅸: 3/4
 𐅰: 500

𒑍: 5      ༳: -1/2   捌: 8      ㊶: 41     ꠵: 3/16   𐹾: 2/3    卅: 30     ㊾:
49     𒐽: 4      𐭹: 2      𐌣: 50     ㈡: 2      𐄧: 6000   〣: 3      〥: 5


༫: 3/2    ㈩: 10     𐄯: 50000  𒐭: 2      ⒒: 11     𒑢: 1/4    𢎐: 2
 𐅟: 5      亖: 4      𐄗: 80     ㆔: 3      𒐕: 1      ⒚: 19     ⅳ: 4
 𐄟: 700

𠦜: 40     𒐝: 9      ⑽: 10     𐤚: 2      ㊆: 7      𐄇: 1      㐅: 5
 三: 3      𐄏: 9      𠦌: 40     𒐍: 8      ⑲: 19     ៳: 3      佰: 100
 𐹶: 500

৷: 1/4    ൴: 1/2    ౺: 2      ፸: 70     百: 100    ⅼ: 50     ⳽: 1/2    𑁢:
80     𝍠: 1      Ⅴ: 5      ⑪: 11     𝍨: 9      ꛩ: 4      𐹮: 60     Ⅸ: 9


Ⅼ: 50     ⓭: 13     𒑒: 4      𐏓: 10     ㉖: 26     ⅔: 2/3    ⒃: 16     𐡚:
3      𐡙: 2      𐭘: 1      ㉞: 34     𐅜: 2      𒑂: 7      參: 3      ㈥: 6


陆: 6      𐅬: 500    𐅄: 50     𒑊: 2      贰: 2      ㉎: 70     𐅌: 500
 ꠲: 3/4    ༰: 13/2   ㊱: 36     ൳: 1/4    ፼: 10000  陸: 6      〺: 30     ㊹:
44

⅐: 1/7    ½: 1/2    𒐢: 5      𐌠: 1      ㈦: 7      𐄤: 3000   㠪: 5
 𐄬: 20000  𒐒: 7      ➓: 10     弐: 2      ↉: 0      𐅔: 1000   𐄔: 50
⒕: 14

𐹽: 1/3    𐄜: 400    𒐂: 4      𒑚: 1/3    ㊁: 2      ↇ: 50000  億:
100000000⒅: 18     𒐊: 5      ㊉: 10     ⅘: 4/5    𐄌: 6      𒐧: 5      ௲:
1000   ⑳: 20

⓰: 16     ⅱ: 2      ৶: 3/16   𐹷: 600    ୵: 1/16   ౻: 3      ⅹ: 10     ៰: 0
     𐭽: 20     𑁣: 90     𐅡: 10     ⅜: 3/8    𝍥: 6      ៷: 7      ⑫: 12


兩: 2      𐹯: 70     ꛬ: 7      𝍭: 50     柒: 7      𒑓: 4      𐅑: 50
㉗: 27     𑁛: 10     𐅙: 1      ㉟: 35     𐭝: 20     参: 3      𒑃: 7
 𐅁: 1/2

𐩇: 1000   𐭻: 4      𒑋: 3      𐅉: 10     ㉏: 80     㭍: 7      𐅩: 50
꠳: 1/16   𐄱: 70000  ፴: 30     ㊴: 39     𒐻: 3      ㊼: 47     𐭸: 1
 𒐣: 2

𠄡: 5      ㈧: 8      𒐫: 9      𐄩: 8000   ༭: 7/2    𒐓: 8      廾: 9
 𐄑: 20     ⅷ: 8      五: 5      𝍣: 4      𒐛: 7      ⒘: 17     𐄙: 100
 𒐬: 1

𒐃: 5      𐄡: 900    𑁡: 70     ↆ: 50     万: 10000  ㊄: 5      𒐋: 6
 𐄉: 3      二: 2      弍: 2      ୲: 1/4    ⓳: 19     ⑰: 17     𐤙: 100
 𐅶: 1/2

𐅤: 10     ៵: 5      𐭺: 3      𐅝: 2      ౸: 0      ৹: 16     ⅾ: 500    廿:
20     𐹼: 1/4    𝍢: 3      ꛪ: 5      𑁠: 60     𐅦: 50     ꛧ: 2      𐅫:
300

𝍪: 20     ⓫: 11     Ⅾ: 500    ꛯ: 0      𐹬: 40     𒑐: 2      六: 6      ⅖:
2/5    𒑛: 2/3    ㉔: 24     𐏕: 100    𐭚: 3      ᛮ: 17     𐡘: 1      𐅞:
2

⒀: 13     𝍰: 80     𐅯: 500    𒐺: 3      𒑀: 6      ㉊: 30     兆:
1000000000000𐩄: 10     𐍊: 900    𒑈: 9      𐹭: 50     𐅎: 5000   ㉌: 50
  陌: 100    ༲: 17/2

貳: 2      𒐰: 4      ㊷: 42     八: 8      ⅓: 1/3    𒐸: 4      亿:
100000000兩: 2      𐌢: 10     𒐠: 3      𐄦: 5000   ㈤: 5      ༪: 1/2    〨:
8      𐄮: 40000

Ⅰ: 1      ⅗: 3/5    ⒓: 12     𒐐: 5      𐤖: 1      𐹱: 90     ⒛: 20
𒐘: 4      𐄞: 600    㒃: 2      𒐀: 2      ↁ: 5000   ㊇: 8      ⅛: 1/8    ⅵ:
6

〦: 6      𒐈: 3      伍: 5      𐄎: 8      〢: 2      ൲: 1000   ⑱: 18     𐹳:
200    ୷: 3/16   ៴: 4      𐹵: 400    𐅆: 5000   ⅻ: 12     ৸: 3/4    ౹: 1


⓾: 10     𐭿: 1000   𐩽: 1      𐅣: 10     𒑡: 1/6    𐹻: 1/2    𝍧: 8
 𠫪: 6      ፶: 50     𑁝: 30     ⓮: 14     𝍯: 70     𦉭: 4      𐅓: 500
 𒑑: 3

❿: 10     𐹴: 300    𐏔: 20     ㉕: 25     𐅛: 2      𒑙: 2      𐭟: 1000
൰: 10     九: 9      ፺: 90     𒑁: 7      𐅀: 1/4    叄: 3      𐩅: 20     ⅴ:
5

𐅋: 100    𒑉: 9      𐹸: 700    𐡛: 10     ㊲: 37     𐄳: 90000  ꠱: 1/2
 𐤗: 10     ㊺: 45     〹: 20     ¾: 3/4    𒑟: 1/8    𐄣: 2000   𒐡: 4
 𐅭: 500

𐄫: 10000  𒐩: 7      貮: 2      ༯: 11/2   𝍡: 2      𐅧: 50     𒐑: 6
 ⒖: 15     𐅚: 1      ⑩: 10     𐤛: 3      𢦘: 3      𒐙: 5      ⅲ: 3
 𒑠: 1/4

𐅏: 5      ㊂: 3      𒐚: 6      ↀ: 1000   𠀁: 7      肆: 4      Ⅶ: 7      ↈ:
100000 ㉍: 60     拾: 10     𐄘: 90     𐹲: 100    ⅰ: 1      ⓱: 17     𒐪: 8


𠁤: 4      ୴: 3/4    𐹺: 900    ⅸ: 9      壹: 1      ౾: 3      ፲: 10     𠫽:
3      𐅪: 100    𐅠: 10     𒐱: 5      𝍤: 5      ፷: 60     𐹪: 20     𒐥:
3

𐅨: 50     𒐁: 3      ⑮: 15     𐅃: 5      𝍬: 40     ꛭ: 8      ㉒: 22
仟: 1000   𐅐: 10     ㉚: 30     𐅮: 500    𐅘: 1      𒐵: 2      𒑞: 2/3
 𐭜: 10

⓯: 15     𒑝: 1/3    ౽: 2      ⒁: 14     𒑆: 9      卄: 20     𐏒: 2
 𐅥: 30     𐅈: 5      𒑎: 6      卌: 40     𐅒: 100    𐄰: 60000  𒐹: 5
 𒐶: 3

㊵: 40     𒐨: 6      𐭼: 10     阡: 1000   𒐾: 4      𑁞: 40     ㊽: 48
㈢: 3      𐄠: 800    𐏑: 1      𒐦: 4      𐅢: 10     𐅖: 50000  𐄨: 7000
𒐮: 3

༬: 5/2    𒐇: 9      𒐤: 3      ㆓: 2      𐄐: 10     ⒑: 10     𒐖: 2
 𐅴: 50     參: 3      𐤘: 20     ⒙: 18     𒐞: 1      𠦃: 30     ㉝: 33
〡: 1


Personally I'm not too sure that ㊱ and ㊱ and co. really deserve to be
parsed...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130712/a5b96d39/attachment-0001.html>


More information about the Python-ideas mailing list