[Tutor] Python-list thread: int vs. float
Alex Kleider
akleider at sonic.net
Sat Feb 11 12:10:04 EST 2017
On 2017-02-11 00:36, eryk sun wrote:
> On Sat, Feb 11, 2017 at 8:06 AM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>> Valid digits for integers include 0 through 9 in decimal
>
> Note that Python 3 uses the Unicode database to determine the decimal
> value of characters, if any. It's not limited to the ASCII decimal
> digits 0-9. For example:
>
> >>> s
> '௧꘢୩'
> >>> int(s)
> 123
> >>> print(*(unicodedata.name(c) for c in s), sep='\n')
> TAMIL DIGIT ONE
> VAI DIGIT TWO
> ORIYA DIGIT THREE
???
alex at X301n3:~$ python3
Python 3.4.3 (default, Nov 17 2016, 01:11:57)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>>
What your 's' represents seems quite different to 'mine.'
There must be something else going on.
???
Also of interest (at least to me) was the 'magic' you demonstrated in
the print function parameter list; my efforts to figure it out:
>>> word = "Hello"
>>> print((c for c in word))
<generator object <genexpr> at 0xb71d125c>
>>> print(*(c for c in word))
H e l l o
>>> print(*(c for c in word), sep='')
Hello
>>>
More information about the Tutor
mailing list