Splitting numeric litterals

MRAB python at mrabarnett.plus.com
Fri Jul 16 10:41:45 EDT 2010


Steven D'Aprano wrote:
> On Fri, 16 Jul 2010 14:49:21 +0100, MRAB wrote:
> 
>> Lawrence D'Oliveiro wrote:
>>> In message <mailman.749.1279159335.1673.python-list at python.org>, MRAB
>>> wrote:
>>>
>>>> Normally it's only string literals that could be so long that you
>>>> might want to split them over several lines. It is somewhat unusual to
>>>> have a _numeric_ literal that's very very long!
>>> Seems a peculiar assumption to make in a language that allows integers
>>> of arbitrary length, does it not?
>> What's the recommended maximum line length in Python? 80 characters? If
>> you take into account indentation, etc, that's still a long integer. And
>> it's still only the _recommended_ maximum.
> 
> Not only that, but it only takes 73 digits to write out the total number 
> of particles in the entire universe:
> 
> 1000000000000000000000000000000000000000000000000000000000000000000000000 
> 
> or 1e72. (Of course that's the lower-bound, estimates range from 1e72 all 
> the way up to 1e87.) So for anything related to counting or labelling 
> actual, physical objects, you will be dealing with smaller numbers than 
> that. E.g. the number of grains of sand on the earth has been estimated 
> (very roughly) as a mere 1000000000000000000000000, or 25 digits.
> 
> It always makes me laugh when I receive an invoice from some company, and 
> the account number or invoice number is (e.g.) 1000000023456789. Who do 
> they think they're fooling? 
> 
It's possible that they're splitting it into fields.



More information about the Python-list mailing list