Numeric literal syntax
steven at REMOVE.THIS.cybersource.com.au
Tue Sep 2 08:56:24 CEST 2008
On Mon, 01 Sep 2008 22:11:13 -0700, Dennis Lee Bieber wrote:
> On Tue, 02 Sep 2008 13:51:16 +1000, Ben Finney
> <bignose+hates-spam at benfinney.id.au> declaimed the following in
>> This is no more the case than for literal strings:
>> a = "spam" "eggs" "ham"
>> a = "spam", "eggs", "ham"
> But... Literal string still have the " (or ') delimiters around the
> components. Such does not exist for you example with integers.
> a = "spam, eggs", "ham"
> a = "spam, eggs" "ham"
Quite frankly, I think that it's a stretch to say that leaving out a
tuple delimiter is a problem with whitespace inside numeric literals.
That's hardly unique to whitespace:
atuple = 5,6,7,8
atuple = 5,67,8
Look Ma, no whitespace!
But even if allowing whitespace inside numeric literals did create a new
avenue for errors which never existed before, it is a mistake to only
consider the downside without the upside. In my opinion, that would be
rather like declaring that the syntax for attribute access is a mistake
because you might do this:
x = MyClass()
xy = 4
instead of this:
x = MyClass()
x.y = 4
At some point the programmer has to take responsibility for typos instead
of blaming the syntax of the language. I agree that we should avoid
syntax that *encourages* typos, but I don't believe that allowing
whitespace inside numeric literals does that.
More information about the Python-list