Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Brett Cannon
Marked as accepted in https://hg.python.org/peps/rev/a52066565cc2 On Thu, 12 May 2016 at 16:59 Guido van Rossum wrote: > Is anyone going to mark the PEP as accepted? > > On Thu, May 12, 2016 at 8:11 AM, Guido van Rossum > wrote: > >> OK, then PEP 515 is now officially accepted! Congratulations.

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Guido van Rossum
Is anyone going to mark the PEP as accepted? On Thu, May 12, 2016 at 8:11 AM, Guido van Rossum wrote: > OK, then PEP 515 is now officially accepted! Congratulations. Start the > implementation work! > > --Guido (mobile) > On May 11, 2016 10:33 PM, "Georg Brandl" wrote: > > I'm happy with the la

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Guido van Rossum
OK, then PEP 515 is now officially accepted! Congratulations. Start the implementation work! --Guido (mobile) On May 11, 2016 10:33 PM, "Georg Brandl" wrote: I'm happy with the latest version. Georg On 05/11/2016 06:46 PM, Guido van Rossum wrote: > If the authors are happy I'll accept it right

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Georg Brandl
I'm happy with the latest version. Georg On 05/11/2016 06:46 PM, Guido van Rossum wrote: > If the authors are happy I'll accept it right away. > > (I vaguely recall there's another PEP that's ready for pronouncement -- but > which one?) > > On Wed, May 11, 2016 at 9:34 AM, Brett Cannon

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Brett Cannon
On Wed, 11 May 2016 at 10:49 Guido van Rossum wrote: > On Wed, May 11, 2016 at 10:28 AM, Brett Cannon wrote: > >> >> >> On Wed, 11 May 2016 at 09:47 Guido van Rossum wrote: >> >>> If the authors are happy I'll accept it right away. >>> >>> (I vaguely recall there's another PEP that's ready for

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Guido van Rossum
On Wed, May 11, 2016 at 10:28 AM, Brett Cannon wrote: > > > On Wed, 11 May 2016 at 09:47 Guido van Rossum wrote: > >> If the authors are happy I'll accept it right away. >> >> (I vaguely recall there's another PEP that's ready for pronouncement -- >> but which one?) >> > > PEP 509 is the only on

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Brett Cannon
On Wed, 11 May 2016 at 09:47 Guido van Rossum wrote: > If the authors are happy I'll accept it right away. > > (I vaguely recall there's another PEP that's ready for pronouncement -- > but which one?) > PEP 509 is the only one I can think of. -Brett > > On Wed, May 11, 2016 at 9:34 AM, Brett

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Guido van Rossum
If the authors are happy I'll accept it right away. (I vaguely recall there's another PEP that's ready for pronouncement -- but which one?) On Wed, May 11, 2016 at 9:34 AM, Brett Cannon wrote: > Is there anything holding up PEP 515 at this point in terms of acceptance > or implementation? > > O

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-11 Thread Brett Cannon
Is there anything holding up PEP 515 at this point in terms of acceptance or implementation? On Sat, 19 Mar 2016 at 11:56 Guido van Rossum wrote: > All that sounds fine! > > On Sat, Mar 19, 2016 at 11:28 AM, Stefan Krah wrote: > > Guido van Rossum python.org> writes: > >> So should the preproc

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Guido van Rossum
All that sounds fine! On Sat, Mar 19, 2016 at 11:28 AM, Stefan Krah wrote: > Guido van Rossum python.org> writes: >> So should the preprocessing step just be s.replace('_', ''), or should >> it reject underscores that don't follow the rules from the PEP >> (perhaps augmented so they follow the s

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Stefan Krah
Guido van Rossum python.org> writes: > So should the preprocessing step just be s.replace('_', ''), or should > it reject underscores that don't follow the rules from the PEP > (perhaps augmented so they follow the spirit of the PEP and the letter > of the IBM spec)? > > Honestly I think it's als

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Guido van Rossum
So should the preprocessing step just be s.replace('_', ''), or should it reject underscores that don't follow the rules from the PEP (perhaps augmented so they follow the spirit of the PEP and the letter of the IBM spec)? Honestly I think it's also fine if specifying this exactly is left out of t

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Stefan Krah
Guido van Rossum python.org> writes: > I don't care too much either way, but I think passing underscores to the constructor shouldn't be affected by the context -- the underscores are just removed before parsing the number. But if it's too complicated to implement I'm fine with punting. Just rem

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Guido van Rossum
I don't care too much either way, but I think passing underscores to the constructor shouldn't be affected by the context -- the underscores are just removed before parsing the number. But if it's too complicated to implement I'm fine with punting. --Guido (mobile) On Mar 19, 2016 6:24 AM, "Nick C

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Nick Coghlan
On 19 March 2016 at 16:44, Georg Brandl wrote: > On the other hand, assuming decimal literals are introduced at some > point, they would almost definitely need to support underscores. > Of course, the decision whether to modify the Decimal constructor > can be postponed until that time. The idea

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Brett Cannon
Where did this PEP leave off? Anything blocking its acceptance? On Sat, 13 Feb 2016 at 00:49 Georg Brandl wrote: > Hi all, > > after talking to Guido and Serhiy we present the next revision > of this PEP. It is a compromise that we are all happy with, > and a relatively restricted rule that mak

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-19 Thread Georg Brandl
I'll update the text so that the format() gets promoted from optional to specified. There was one point of discussion in the tracker issue that should be resolved before acceptance: the Decimal constructor is listed as getting updated to allow underscores, but its syntax is specified in the Decima

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-03-18 Thread Guido van Rossum
I'm happy to accept this PEP as is stands, assuming the authors are ready for this news. I recommend also implementing the option from footnote [11] (extend the number-to-string formatting language to allow ``_`` as a thousans separator). On Thu, Mar 17, 2016 at 11:19 AM, Brett Cannon wrote: > Wh

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Brett Cannon
On Sat, Feb 13, 2016, 00:49 Georg Brandl wrote: > Hi all, > > after talking to Guido and Serhiy we present the next revision > of this PEP. It is a compromise that we are all happy with, > and a relatively restricted rule that makes additions to PEP 8 > basically unnecessary. > +1 from me. >

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Ethan Furman
On 02/13/2016 12:48 AM, Georg Brandl wrote: The remaining open question is about the reverse direction: do we want a string formatting modifier that adds underscores as thousands separators? +0 Would be nice, but also wouldn't make much sense in other groupings. Instead of the relatively s

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Glenn Linderman
On 2/13/2016 12:48 AM, Georg Brandl wrote: Instead of the relatively strict rule specified above, the use of underscores could be limited. This sentence doesn't really make sense. Either s/limited/more limited/ or s/limited/further limited/ or s/limited/relaxed/ Maybe the whole section should

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Steven D'Aprano
On Sat, Feb 13, 2016 at 09:48:49AM +0100, Georg Brandl wrote: > Hi all, > > after talking to Guido and Serhiy we present the next revision > of this PEP. It is a compromise that we are all happy with, > and a relatively restricted rule that makes additions to PEP 8 > basically unnecessary. > > I

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Georg Brandl
On 02/13/2016 12:10 PM, Serhiy Storchaka wrote: > On 13.02.16 10:48, Georg Brandl wrote: >> Following the same rules for placement, underscores will be allowed in >> the following constructors: >> >> - ``int()`` (with any base) >> - ``float()`` >> - ``complex()`` >> - ``Decimal()`` > > What about

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Serhiy Storchaka
On 13.02.16 10:48, Georg Brandl wrote: Following the same rules for placement, underscores will be allowed in the following constructors: - ``int()`` (with any base) - ``float()`` - ``complex()`` - ``Decimal()`` What about float.fromhex()? Should underscores be allowed in it (I think no)?

[Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-02-13 Thread Georg Brandl
Hi all, after talking to Guido and Serhiy we present the next revision of this PEP. It is a compromise that we are all happy with, and a relatively restricted rule that makes additions to PEP 8 basically unnecessary. I think the discussion has shown that supporting underscores in the from-string

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread Paul Moore
On 12 February 2016 at 20:06, Chris Barker wrote: > As Paul said, as long as I can do the above, I'll be fine, but I think > everyone's source code will be a lot cleaner in the long run if you don't > have the option of doing who knows what weird arrangement Just to be clear, I'm personally i

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread Andrew Barnert via Python-Dev
On Feb 12, 2016, at 12:58, Glenn Linderman wrote: > >> On 2/12/2016 12:06 PM, Chris Barker wrote: >> As for the SS# example -- it seems a bad idea to me to store a SS# number as >> an integer anyway -- so all the weird IDs etc. formats aren't really >> relevant... > > SS#... why not integer?

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread Glenn Linderman
On 2/12/2016 12:06 PM, Chris Barker wrote: On Fri, Feb 12, 2016 at 1:00 AM, Paul Moore > wrote: I have no opinion on anything other than that whatever syntax is implemented as long as it allows single underscores between digits, such as 1_000_000

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread MRAB
On 2016-02-12 20:06, Chris Barker wrote: On Fri, Feb 12, 2016 at 1:00 AM, Paul Moore mailto:p.f.mo...@gmail.com>> wrote: I have no opinion on anything other than that whatever syntax is implemented as long as it allows single underscores between digits, such as 1_000_000 E

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread Chris Barker
On Fri, Feb 12, 2016 at 1:00 AM, Paul Moore wrote: > > I have no opinion on anything other than that whatever syntax is > implemented as long as it allows single underscores between digits, > such as > > 1_000_000 > > Everything else is irrelevant to me, and if I read code that uses > anything el

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-12 Thread Paul Moore
On 12 February 2016 at 00:16, Steven D'Aprano wrote: > I think that there is broad agreement that: > > - the basic idea is sound > - leading underscores followed by digits are currently legal > identifiers and this will not change > - underscores should not follow the sign - + > - underscores sh

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 8:22 PM, Andrew Barnert wrote: On Thursday, February 11, 2016 8:10 PM, Glenn Linderman wrote: On 2/11/2016 7:56 PM, David Mertz wrote: Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use grouping in twos. https:

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Thursday, February 11, 2016 8:10 PM, Glenn Linderman wrote: >On 2/11/2016 7:56 PM, David Mertz wrote: > >Great PEP overall. We definitely don't want the restriction to grouping >numbers only in threes. South Asian crore use grouping in twos. >>https://en.m.wikipedia.org/wiki/Crore >> >Intere

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 7:56 PM, David Mertz wrote: Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use grouping in twos. https://en.m.wikipedia.org/wiki/Crore Interesting... 3 digits in the least significant group, and _then_ by twos

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread David Mertz
Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use grouping in twos. https://en.m.wikipedia.org/wiki/Crore On Feb 11, 2016 7:04 PM, "Glenn Linderman" wrote: > On 2/11/2016 4:16 PM, Steven D'Aprano wrote: > > On Thu, Feb 11, 2016

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 4:16 PM, Steven D'Aprano wrote: On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: And honestly, are you really claiming that in your opinion, "123_456

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Thursday, February 11, 2016 10:35 AM, Jeff Hardy wrote: >On Thu, Feb 11, 2016 at 10:15 AM, Andrew Barnert via Python-Dev > wrote: > >>That's a good point: we need style rules for PEP 8. ... >>It might be simpler to write a "whitelist" than a "blacklist" of all the ugly >>things people migh

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Martin Panter
On 12 February 2016 at 00:16, Steven D'Aprano wrote: > On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: >> On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: >> >> > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: >> > >> > > And honestly, are you really claiming tha

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Martin Panter
On 11 February 2016 at 11:12, Chris Angelico wrote: > On Thu, Feb 11, 2016 at 7:22 PM, Georg Brandl wrote: The following extensions are open for discussion: >> * Allowing underscores in string arguments to the ``Decimal`` constructor. >> It >> could be argued that these are akin to literals

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: > On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: > > > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > > > > > And honestly, are you really claiming that in your opinion, "123_456_" > > > is worse than all of the

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 08:50:09PM +0200, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by most > other languages -- "only between two digits". Main arguments: > > 1. Simple rule is easier to understand, remember and recognize. I care > not about the

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 12:22 AM, Georg Brandl wrote: Hey all, based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. +1 overall Examples:: # grouping decimal numbers by thousands

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 11:01 AM, Ethan Furman wrote: On 02/11/2016 10:50 AM, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by > most other languages -- "only between two digits". Main arguments: > 2. Most languages use this rule. It is better to follow non-forma

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Ethan Furman
On 02/11/2016 10:50 AM, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by > most other languages -- "only between two digits". Main arguments: > 2. Most languages use this rule. It is better to follow non-formal > standard that invent the rule that diffe

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 10:22, Georg Brandl wrote: Abstract and Rationale == This PEP proposes to extend Python's syntax so that underscores can be used in integral, floating-point and complex number literals. This is a common feature of other modern languages, and can aid readability o

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Jeff Hardy
On Thu, Feb 11, 2016 at 10:15 AM, Andrew Barnert via Python-Dev < python-dev@python.org> wrote: > On Feb 11, 2016, at 09:39, Terry Reedy wrote: > > > > If trailing _ is allowed, to simplify the implementation, I would like > PEP 8, while on the subject, to say something like "While trailing _s on

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 10:15, Andrew Barnert via Python-Dev wrote: > > That's a good point: we need style rules for PEP 8. One more point: should the tutorial mention underscores? It looks like the intro docs for a lot of the other languages do. And it would only take one short sentence in 3.1.1

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 19:40, Georg Brandl wrote: On 02/11/2016 06:19 PM, Serhiy Storchaka wrote: Thanks for the alternate patch. I used the two-function approach you took in ast.c for my latest revision. I still think that some cases (like two of the examples in the PEP, 0b__ and 1.5_j) are wor

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 09:39, Terry Reedy wrote: > > If trailing _ is allowed, to simplify the implementation, I would like PEP 8, > while on the subject, to say something like "While trailing _s on numbers are > allowed, to simplify the implementation, they serve no purpose and are > strongly di

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Brett Cannon
On Thu, 11 Feb 2016 at 00:23 Georg Brandl wrote: > Hey all, > > based on the feedback so far, I revised the PEP. There is now > a much simpler rule for allowed underscores, with no exceptions. > This made the grammar simpler as well. > > --

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Brett Cannon
On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > > > And honestly, are you really claiming that in your opinion, "123_456_" > > is worse than all of their other examples, like "1_23__4"? > > Yes I am, because 123_456_ looks li

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Ethan Furman
On 02/11/2016 09:19 AM, Serhiy Storchaka wrote: On 11.02.16 14:14, Georg Brandl wrote: I still think that some cases (like two of the examples in the PEP, 0b__ and 1.5_j) are worth having, and therefore a more relaxed rule is preferable. Should I write an alternative PEP for strong r

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 06:19 PM, Serhiy Storchaka wrote: >> Thanks for the alternate patch. I used the two-function approach you took >> in ast.c for my latest revision. >> >> I still think that some cases (like two of the examples in the PEP, >> 0b__ and 1.5_j) are worth having, and therefore a m

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Terry Reedy
On 2/11/2016 2:45 AM, Georg Brandl wrote: Thanks for grabbing this issue and moving it forward. I will like being about to write or read 200_000_000 and be sure I an right without counting 0s. Based on the feedback so far, I have an easier rule in mind that I will base the next PEP revision

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 14:14, Georg Brandl wrote: On 02/11/2016 11:17 AM, Serhiy Storchaka wrote: **Group 3: only between digits, only one underscore** * Ada [8]_ * Julia (but not in the exponent part of floats) [9]_ * Ruby (docs say "anywhere", in reality only between digits) [10]_ C++ is in this grou

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Barry Warsaw
On Feb 11, 2016, at 05:57 PM, Georg Brandl wrote: >D'oh :) I added (hopefully) clarifying wording. I saw the diff - perfect! Thanks. -Barry ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscr

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steve Dower
On 11Feb2016 0651, Barry Warsaw wrote: On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. I'd be +1, but there's something miss

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 05:52 PM, Steve Dower wrote: > On 11Feb2016 0651, Barry Warsaw wrote: >> On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: >> >>> based on the feedback so far, I revised the PEP. There is now >>> a much simpler rule for allowed underscores, with no exceptions. >>> This made the gramm

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 00:22, Georg Brandl wrote: > > Allowing underscores in string arguments to the ``Decimal`` constructor. It > could be argued that these are akin to literals, since there is no Decimal > literal available (yet). I'm +1 on this. Partly for consistency (see below)--but also,

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 02:13, Steven D'Aprano wrote: > >> On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: >> 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, b

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Barry Warsaw
On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: >based on the feedback so far, I revised the PEP. There is now >a much simpler rule for allowed underscores, with no exceptions. >This made the grammar simpler as well. I'd be +1, but there's something missing from the PEP: what the underscores *

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 11:17 AM, Serhiy Storchaka wrote: >> **Group 3: only between digits, only one underscore** >> >> * Ada [8]_ >> * Julia (but not in the exponent part of floats) [9]_ >> * Ruby (docs say "anywhere", in reality only between digits) [10]_ > > C++ is in this group too. > > The documenta

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 7:22 PM, Georg Brandl wrote: > * Allowing underscores in string arguments to the ``Decimal`` constructor. It > could be argued that these are akin to literals, since there is no Decimal > literal available (yet). > > * Allowing underscores in string arguments to ``int(

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 08:07:56PM +1000, Nick Coghlan wrote: > Given that str.format supports a thousands separator: > > >>> "{:,d}".format(1) > '100,000,000' > > it might be reasonable to permit "_" in place of "," in the format specifier. +1 > However, I'm not sure when you'd use i

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Petr Viktorin
On 02/11/2016 11:07 AM, Nick Coghlan wrote: > On 11 February 2016 at 19:59, Victor Stinner wrote: >> 2016-02-11 9:11 GMT+01:00 Georg Brandl : >>> On 02/11/2016 12:04 AM, Victor Stinner wrote: It looks like the implementation https://bugs.python.org/issue26331 only changes the Python pars

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 00:20, Georg Brandl wrote: **Group 1: liberal (like this PEP)** * D [2]_ * Perl 5 (although docs say it's more restricted) [3]_ * Rust [4]_ * Swift (although textual description says "between digits") [5]_ **Group 2: only between digits, multiple consecutive underscores** * C# (ope

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > And honestly, are you really claiming that in your opinion, "123_456_" > is worse than all of their other examples, like "1_23__4"? Yes I am, because 123_456_ looks like you've forgotten to finish typing the last group of digits,

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Nick Coghlan
On 11 February 2016 at 19:59, Victor Stinner wrote: > 2016-02-11 9:11 GMT+01:00 Georg Brandl : >> On 02/11/2016 12:04 AM, Victor Stinner wrote: >>> It looks like the implementation https://bugs.python.org/issue26331 >>> only changes the Python parser. >>> >>> What about other functions converting

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Victor Stinner
2016-02-11 9:11 GMT+01:00 Georg Brandl : > On 02/11/2016 12:04 AM, Victor Stinner wrote: >> It looks like the implementation https://bugs.python.org/issue26331 >> only changes the Python parser. >> >> What about other functions converting strings to numbers at runtime >> like int(str) and float(str

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 10:10 AM, Paul Moore wrote: > On 10 February 2016 at 23:14, Steven D'Aprano wrote: >> On Wed, Feb 10, 2016 at 10:53:09PM +, Paul Moore wrote: >>> On 10 February 2016 at 22:20, Georg Brandl wrote: >>> > This came up in python-ideas, and has met mostly positive comments, >>> > alt

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Paul Moore
On 10 February 2016 at 23:14, Steven D'Aprano wrote: > On Wed, Feb 10, 2016 at 10:53:09PM +, Paul Moore wrote: >> On 10 February 2016 at 22:20, Georg Brandl wrote: >> > This came up in python-ideas, and has met mostly positive comments, >> > although the exact syntax rules are up for discussi

[Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
Hey all, based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. --- PEP: 515 Title: Underscores in Numeric Liter

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 12:04 AM, Victor Stinner wrote: > It looks like the implementation https://bugs.python.org/issue26331 > only changes the Python parser. > > What about other functions converting strings to numbers at runtime > like int(str) and float(str)? Paul also asked for Decimal(str). I added t

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/10/2016 11:42 PM, Glenn Linderman wrote: > On 2/10/2016 2:20 PM, Georg Brandl wrote: >> This came up in python-ideas, and has met mostly positive comments, >> although the exact syntax rules are up for discussion. >> >> cheers, >> Georg >> >> --

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Georg Brandl
On 02/10/2016 11:35 PM, Brett Cannon wrote: >> Examples:: >> >> # grouping decimal numbers by thousands >> amount = 10_000_000.0 >> >> # grouping hexadecimal addresses by words >> addr = 0xDEAD_BEEF >> >> # grouping bits into bytes in a binary literal

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Georg Brandl
On 02/11/2016 12:45 AM, Andrew Barnert via Python-Dev wrote: > On Feb 10, 2016, at 14:20, Georg Brandl wrote: > > First, general questions: should the PEP mention the Decimal constructor? > What about int and float (I'd assume int(s) continues to work as always, > while int(s, 0) gets the new beh

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Georg Brandl
On 02/11/2016 02:16 AM, Martin Panter wrote: > I have occasionally wondered about this missing feature. > > On 10 February 2016 at 22:20, Georg Brandl wrote: >> Abstract and Rationale >> == >> >> This PEP proposes to extend Python's syntax so that underscores can be used >> i

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Andrew Barnert via Python-Dev
On Feb 10, 2016, at 16:21, Steven D'Aprano wrote: > >> On Wed, Feb 10, 2016 at 03:45:48PM -0800, Andrew Barnert via Python-Dev >> wrote: >> On Feb 10, 2016, at 14:20, Georg Brandl wrote: >> >> First, general questions: should the PEP mention the Decimal constructor? >> What about int and floa

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Martin Panter
I have occasionally wondered about this missing feature. On 10 February 2016 at 22:20, Georg Brandl wrote: > Abstract and Rationale > == > > This PEP proposes to extend Python's syntax so that underscores can be used in > integral and floating-point number literals. This shou

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Steven D'Aprano
On Wed, Feb 10, 2016 at 03:45:48PM -0800, Andrew Barnert via Python-Dev wrote: > On Feb 10, 2016, at 14:20, Georg Brandl wrote: > > First, general questions: should the PEP mention the Decimal constructor? > What about int and float (I'd assume int(s) continues to work as always, > while int(s,

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Ethan Furman
On 02/10/2016 04:04 PM, Steven D'Aprano wrote: > change to a single rule "one or more underscores may appear between > two (hex)digits, but otherwise nowhere else". That's much simpler to > understand than a series of restrictions as given above. I like the simpler rule, but I would also allow

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Steven D'Aprano
On Wed, Feb 10, 2016 at 11:20:38PM +0100, Georg Brandl wrote: > This came up in python-ideas, and has met mostly positive comments, > although the exact syntax rules are up for discussion. Nicely done. But I would change the restrictions to a simpler version. Instead of five rules to learn: > T

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Andrew Barnert via Python-Dev
On Feb 10, 2016, at 14:20, Georg Brandl wrote: First, general questions: should the PEP mention the Decimal constructor? What about int and float (I'd assume int(s) continues to work as always, while int(s, 0) gets the new behavior, but if that isn't obviously true, it may be worth saying expl

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Steven D'Aprano
On Wed, Feb 10, 2016 at 10:53:09PM +, Paul Moore wrote: > On 10 February 2016 at 22:20, Georg Brandl wrote: > > This came up in python-ideas, and has met mostly positive comments, > > although the exact syntax rules are up for discussion. > > +1 on the PEP. Is there any value in allowing unde

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread MRAB
On 2016-02-10 22:35, Brett Cannon wrote: [snip] Examples:: # grouping decimal numbers by thousands amount = 10_000_000.0 # grouping hexadecimal addresses by words addr = 0xDEAD_BEEF # grouping bits into bytes in a binary literal flags

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Victor Stinner
It looks like the implementation https://bugs.python.org/issue26331 only changes the Python parser. What about other functions converting strings to numbers at runtime like int(str) and float(str)? Paul also asked for Decimal(str). Victor ___ Python-Dev

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Paul Moore
On 10 February 2016 at 22:20, Georg Brandl wrote: > This came up in python-ideas, and has met mostly positive comments, > although the exact syntax rules are up for discussion. +1 on the PEP. Is there any value in allowing underscores in strings passed to the Decimal constructor as well? The same

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Glenn Linderman
On 2/10/2016 2:20 PM, Georg Brandl wrote: This came up in python-ideas, and has met mostly positive comments, although the exact syntax rules are up for discussion. cheers, Georg PEP: 515 Title: Underscores in Num

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Brett Cannon
On Wed, 10 Feb 2016 at 14:21 Georg Brandl wrote: > This came up in python-ideas, and has met mostly positive comments, > although the exact syntax rules are up for discussion. > > cheers, > Georg > > > > > PEP: 515 >

[Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-10 Thread Georg Brandl
This came up in python-ideas, and has met mostly positive comments, although the exact syntax rules are up for discussion. cheers, Georg PEP: 515 Title: Underscores in Numeric Literals Version: $Revision$ Last-Modif