Underscores in Python numbers

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sat Nov 19 04:33:40 EST 2005


Steven D'Aprano:
> Perhaps Python should concatenate numeric literals at compile time:
> 123 456 is the same as 123456.

I think using the underscore it is more explicit:
n = 123_456

Alternatively the underscore syntax may be used to separate the number
from its base:
22875 == 22875_10 == 595b_16 == 123456_7
But probably this is less commonly useful (and not much explicit).

Bye,
bearophile




More information about the Python-list mailing list