Underscores in Python numbers

Eric Jacoboni jaco at neottia.net
Sun Nov 20 09:50:10 EST 2005


Mike Meyer <mwm at mired.org> writes:

> I've seen at least one language (forget which one) that allowed such
> separators, but only for groups of three. So 123_456 would be valid,
> but 9_1 would be a syntax error. 

Ada allows underscores in numeric literals since 1983, without
enforcing any grouping. The Ruby language allows also this
notation. You may write 1_000_001 or 1000_001 or 10_00_001, etc. (the
same for real numbers...). 

When you have the habit to represent literals like that, all other
big numeric literals or workarounds to create grouping seem cryptic. 

-- 
Eric Jacoboni, ne il y a 1435938104 secondes



More information about the Python-list mailing list