Message251915
Summary: This is about int(u'१२३४') == 1234.
At https://docs.python.org/2/library/functions.html and also https://docs.python.org/3/library/functions.html the documentation for
class int(x=0)
class int(x, base=10)
says (respectively):
> If x is not a number or if base is given, then x must be a string or Unicode object representing an integer literal in radix base.
> If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in radix base.
If you follow the definition of "integer literal" into the reference (https://docs.python.org/2/reference/lexical_analysis.html#integers and https://docs.python.org/3/reference/lexical_analysis.html#integers respectively), the definitions ultimately involve
nonzerodigit ::= "1"..."9"
octdigit ::= "0"..."7"
bindigit ::= "0" | "1"
digit ::= "0"..."9"
So it looks like whether the behaviour of int() conforms to its documentation hinges on what "representing" means. Apparently it is some definition under which u'१२३४' represents the integer literal 1234, but it would be great to either clarify the documentation of int() or change its behaviour. |
|
Date |
User |
Action |
Args |
2015-09-30 05:19:46 | shreevatsa | set | recipients:
+ shreevatsa, vstinner, ezio.melotti, docs@python |
2015-09-30 05:19:45 | shreevatsa | set | messageid: <1443590385.97.0.810723896221.issue25275@psf.upfronthosting.co.za> |
2015-09-30 05:19:45 | shreevatsa | link | issue25275 messages |
2015-09-30 05:19:44 | shreevatsa | create | |
|