[Python-Dev] PEP 515: Underscores in Numeric Literals (original) (raw)

Steven D'Aprano steve at pearwood.info
Thu Feb 11 05:13:27 EST 2016


On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote:

And honestly, are you really claiming that in your opinion, "123456" is worse than all of their other examples, like "123_4"?

Yes I am, because 123_456_ looks like you've forgotten to finish typing the last group of digits, while 1_23__4 merely looks like you have no taste.

They're both presented as something the syntax allows, and neither one looks like something I'd ever want to write, much less promote in a style guide or something, but neither one screams out as something that's so heinous we need to complicate the language to ensure it raises a SyntaxError. Yes, that's my opinion, but do.you really have a different opinion about any part of that?

I don't think the rule "underscores must occur between digits" is complicating the specification. It is less complicated to explain this rule than to give a whole lot of special cases

versus

I'm not sure why you seem to think that "only between digits" is more complex than the alternative -- to me it is less complex, with no special cases to memorise, just one general rule.

Of course, if (generic) you think that it is a feature to be able to put underscores before the decimal point, after the E exponent, etc. then you will dislike my suggested rule. That's okay, but in that case, it is not because of "simplicity|complexity" but because (generic) you want to be able to write things which my rule would prohibit.

-- Steve



More information about the Python-Dev mailing list