[Python-Dev] Fourth (final?) preview of rc2 is up

2014-02-22 Thread Larry Hastings
Only three new revisions this time. Victor must have taken the day off! //arry/ ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Ethan Furman
On 02/21/2014 10:57 PM, Stephen J. Turnbull wrote: Ethan Furman writes: On 02/21/2014 07:46 PM, Chris Angelico wrote: but not this: value = expr except Exception: default except Exception: default This should be the way it works. Nothing is gained in readability by turning a try with

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 15:57:02 +0900 Stephen J. Turnbull step...@xemacs.org wrote: try: interpolable = func(key) except TypeError: interpolable = not a string: %s % key except KeyError: interpolable = no such key: %s % key print(Some message that

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Fri, 21 Feb 2014 09:37:29 -0800 Guido van Rossum gu...@python.org wrote: I'm put off by the ':' syntax myself (it looks to me as if someone forgot a newline somewhere) but 'then' feels even weirder (it's been hard-coded in my brain as meaning the first branch of an 'if'). Would 'else' work

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 16:12:27 +0900 Stephen J. Turnbull step...@xemacs.org wrote: Note in support: I originally thought that get methods would be more efficient, but since Nick pointed out that haveattr is implemented by catching the exception (Yikes! LBYL implemented by using EAFP!), I

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Fri, 21 Feb 2014 19:49:20 -0700 Eric Snow ericsnowcurren...@gmail.com wrote: On Fri, Feb 21, 2014 at 7:07 PM, Victor Stinner victor.stin...@gmail.com wrote: Consider this example of a two-level cache:: for key in sequence: x = (lvl1[key] except KeyError: (lvl2[key] except

Re: [Python-Dev] One more cherry-pick request for 3.4.0 that I'd like a little public debate on

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 01:42:57 -0600 Larry Hastings la...@hastings.org wrote: Victor has asked me to cherry-pick 180e4b678003: http://bugs.python.org/issue20320 (original issue) http://hg.python.org/cpython/rev/180e4b678003/ (checkin into trunk)

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 8:20 PM, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 22 Feb 2014 16:12:27 +0900 Stephen J. Turnbull step...@xemacs.org wrote: Note in support: I originally thought that get methods would be more efficient, but since Nick pointed out that haveattr is implemented

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:57 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Nick Coghlan wrote: As Chris later noted, you likely *could* still implement expression local name binding for an except expression without a full closure, it would just be rather difficult. I'm still not

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 20:29:27 +1100 Chris Angelico ros...@gmail.com wrote: Which means that, fundamentally, EAFP is the way to do it. So if PEP 463 expressions had existed from the beginning, hasattr() probably wouldn't have been written - people would just use an except-expression instead.

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 8:58 PM, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 22 Feb 2014 20:29:27 +1100 Chris Angelico ros...@gmail.com wrote: Which means that, fundamentally, EAFP is the way to do it. So if PEP 463 expressions had existed from the beginning, hasattr() probably

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Thomas Wouters
On Fri, Feb 21, 2014 at 7:46 PM, Chris Angelico ros...@gmail.com wrote: On Sat, Feb 22, 2014 at 9:06 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Nick Coghlan wrote: On 21 February 2014 13:15, Chris Angelico ros...@gmail.com wrote: Generator expressions require parentheses,

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 21:09:07 +1100 Chris Angelico ros...@gmail.com wrote: On Sat, Feb 22, 2014 at 8:58 PM, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 22 Feb 2014 20:29:27 +1100 Chris Angelico ros...@gmail.com wrote: Which means that, fundamentally, EAFP is the way to do it. So if

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Stephen J. Turnbull
Antoine Pitrou writes: Well, the only way to know that a key (or attribute) exists is to do the lookup. What else would you suggest? Do the lookup at the C level (or whatever the implementation language is) and generate no exception, of course. That's what would make it possibly more

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On sam., 2014-02-22 at 19:29 +0900, Stephen J. Turnbull wrote: Antoine Pitrou writes: Well, the only way to know that a key (or attribute) exists is to do the lookup. What else would you suggest? Do the lookup at the C level (or whatever the implementation language is) and generate no

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Greg Ewing
Chris Angelico wrote: On Sat, Feb 22, 2014 at 10:57 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: I'm still not convinced it would be all *that* difficult. Seems to me it would be semantically equivalent to renaming the inner variable and adding a finally clause to unbind it. Is there

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 9:17 PM, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 22 Feb 2014 21:09:07 +1100 Chris Angelico ros...@gmail.com wrote: On Sat, Feb 22, 2014 at 8:58 PM, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 22 Feb 2014 20:29:27 +1100 Chris Angelico ros...@gmail.com

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:01 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Chris Angelico wrote: On Sat, Feb 22, 2014 at 10:57 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: I'm still not convinced it would be all *that* difficult. Seems to me it would be semantically equivalent to

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On Sat, 22 Feb 2014 22:13:58 +1100 Chris Angelico ros...@gmail.com wrote: Well, can you propose the corresponding except-expression? It's hard to do hasattr itself without something messy - the best I can come up with is this: hasattr(x,y) - (x.y or True except AttributeError: False)

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 10:27 PM, Antoine Pitrou solip...@pitrou.net wrote: Yeah, none of these examples makes a convincing case that hasattr() is useless, IMO. I'm not trying to make the case that it's useless. I'm trying to show that, if it didn't exist, all of these would be written some

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Stephen J. Turnbull
Antoine Pitrou writes: On sam., 2014-02-22 at 19:29 +0900, Stephen J. Turnbull wrote: Antoine Pitrou writes: Well, the only way to know that a key (or attribute) exists is to do the lookup. What else would you suggest? Do the lookup at the C level (or whatever the

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Antoine Pitrou
On sam., 2014-02-22 at 20:54 +0900, Stephen J. Turnbull wrote: Antoine Pitrou writes: On sam., 2014-02-22 at 19:29 +0900, Stephen J. Turnbull wrote: Antoine Pitrou writes: Well, the only way to know that a key (or attribute) exists is to do the lookup. What else would you

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Stephen J. Turnbull
Antoine Pitrou writes: On Sat, 22 Feb 2014 22:13:58 +1100 Chris Angelico ros...@gmail.com wrote: hasattr(x,y) - (x.y or True except AttributeError: False) But it's not the same. hasattr() returns a boolean, not an arbitrary value. I think he meant hasattr(x,y) - (x.y and True

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Eric V. Smith
On 2/22/2014 6:27 AM, Antoine Pitrou wrote: On Sat, 22 Feb 2014 22:13:58 +1100 Chris Angelico ros...@gmail.com wrote: Lib/inspect.py:1350: return sys._getframe(1) if hasattr(sys, _getframe) else None becomes return (sys._getframe(1) except AttributeError: None) May hide a bug if

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sat, Feb 22, 2014 at 11:14 PM, Stephen J. Turnbull step...@xemacs.org wrote: Antoine Pitrou writes: On Sat, 22 Feb 2014 22:13:58 +1100 Chris Angelico ros...@gmail.com wrote: hasattr(x,y) - (x.y or True except AttributeError: False) But it's not the same. hasattr() returns a

Re: [Python-Dev] Tangent on class level scoping rules (was Re: PEP 463: Exception-catching expressions)

2014-02-22 Thread Nick Coghlan
On 22 Feb 2014 09:59, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Nick Coghlan wrote: As Chris later noted, you likely *could* still implement expression local name binding for an except expression without a full closure, it would just be rather difficult. I'm still not convinced it

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Nick Coghlan
On 22 Feb 2014 22:15, Stephen J. Turnbull step...@xemacs.org wrote: Antoine Pitrou writes: On Sat, 22 Feb 2014 22:13:58 +1100 Chris Angelico ros...@gmail.com wrote: hasattr(x,y) - (x.y or True except AttributeError: False) But it's not the same. hasattr() returns a boolean, not an

Re: [Python-Dev] GSOC 2014

2014-02-22 Thread NAVNEET SUMAN
Thank you for your recommendations Jessica. I am looking forward to work with python this gsoc. On 22 February 2014 08:39, Jessica McKellar jessica.mckel...@gmail.comwrote: Hi Navneet, This is my first year in gsoc. I have been working with python and django from quite a time. One of

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Brett Cannon
On Fri, Feb 21, 2014 at 8:41 PM, Greg Ewing greg.ew...@canterbury.ac.nzwrote: Ethan Furman wrote: On 02/21/2014 03:29 PM, Greg Ewing wrote: value = lst[2] except No value if IndexError It does read nicely, and is fine for the single, non-nested, case (which is probably the vast

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Brett Cannon
On Sat, Feb 22, 2014 at 4:13 AM, Antoine Pitrou solip...@pitrou.net wrote: On Fri, 21 Feb 2014 09:37:29 -0800 Guido van Rossum gu...@python.org wrote: I'm put off by the ':' syntax myself (it looks to me as if someone forgot a newline somewhere) but 'then' feels even weirder (it's been

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Jeff Allen
On 22/02/2014 16:36, Brett Cannon wrote: On Sat, Feb 22, 2014 at 4:13 AM, Antoine Pitrou solip...@pitrou.net mailto:solip...@pitrou.net wrote: On Fri, 21 Feb 2014 09:37:29 -0800 Guido van Rossum gu...@python.org mailto:gu...@python.org wrote: I'm put off by the ':' syntax

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Tim Delaney
On 23 February 2014 02:29, Nick Coghlan ncogh...@gmail.com wrote: On 22 Feb 2014 22:15, Stephen J. Turnbull step...@xemacs.org wrote: Antoine Pitrou writes: Chris Angelico ros...@gmail.com wrote: hasattr(x,y) - (x.y or True except AttributeError: False) But it's not the same.

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Nikolaus Rath
Stephen J. Turnbull step...@xemacs.org writes: Ethan Furman writes: On 02/21/2014 07:46 PM, Chris Angelico wrote: but not this: value = expr except Exception: default except Exception: default This should be the way it works. Nothing is gained in readability by

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Stephen J. Turnbull
Antoine Pitrou writes: Sure, but complaining about inefficiencies without asserting their significance is not very useful. Since you completely missed the point of my post, I'll explain. I was in no way complaining about inefficiencies. My point was precisely the opposite: to the extent

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Thomas Wouters
On Sat, Feb 22, 2014 at 2:08 AM, Thomas Wouters tho...@python.org wrote: (FWIW, I have a working patch without tests that allows all of these, I'll upload it tonight so people can play with it. Oh, and FWIW, currently I'm +0 on the idea, -0 on the specific syntax.)

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Chris Angelico
On Sun, Feb 23, 2014 at 11:00 AM, Thomas Wouters tho...@python.org wrote: On Sat, Feb 22, 2014 at 2:08 AM, Thomas Wouters tho...@python.org wrote: (FWIW, I have a working patch without tests that allows all of these, I'll upload it tonight so people can play with it. Oh, and FWIW, currently

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread MRAB
On 2014-02-23 00:09, Chris Angelico wrote: On Sun, Feb 23, 2014 at 11:00 AM, Thomas Wouters tho...@python.org wrote: On Sat, Feb 22, 2014 at 2:08 AM, Thomas Wouters tho...@python.org wrote: (FWIW, I have a working patch without tests that allows all of these, I'll upload it tonight so

Re: [Python-Dev] PEP 463: Exception-catching expressions

2014-02-22 Thread Nick Coghlan
On 23 February 2014 11:11, MRAB pyt...@mrabarnett.plus.com wrote: On 2014-02-23 00:09, Chris Angelico wrote: On Sun, Feb 23, 2014 at 11:00 AM, Thomas Wouters tho...@python.org wrote: On Sat, Feb 22, 2014 at 2:08 AM, Thomas Wouters tho...@python.org wrote: (FWIW, I have a working patch

[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Ethan Furman
Greetings, all! I think I'm about ready to ask for pronouncement for this PEP, but I would like opinions on the Open Questions question so I can close it. :) Please let me know if anything else needs tweaking. -- PEP: 461 Title: Adding %

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Ethan Furman
Sorry, found a couple more comments in a different thread. Here's what I added: +Objections +== + +The objections raised against this PEP were mainly variations on two themes:: + + - the ``bytes`` and ``bytearray`` types are for pure binary data, with no +assumptions about

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Chris Angelico
On Sun, Feb 23, 2014 at 12:56 PM, Ethan Furman et...@stoneleaf.us wrote: Open Questions == It has been suggested to use ``%b`` for bytes as well as ``%s``. - Pro: clearly says 'this is bytes'; should be used for new code. - Con: does not exist in Python 2.x, so we would

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Mark Lawrence
On 23/02/2014 02:30, Ethan Furman wrote: +be any more of a nuisance than the already existing methdods. Typo methdods. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Cameron Simpson
On 22Feb2014 17:56, Ethan Furman et...@stoneleaf.us wrote: Please let me know if anything else needs tweaking. [...] This area of programming is characterized by a mixture of binary data and ASCII compatible segments of text (aka ASCII-encoded text). [...] %-interpolation All the numeric

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Ethan Furman
On 02/22/2014 07:29 PM, Mark Lawrence wrote: On 23/02/2014 02:30, Ethan Furman wrote: +be any more of a nuisance than the already existing methdods. Typo methdods. Thanks, fixed. -- ~Ethan~ ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Ethan Furman
On 02/22/2014 07:47 PM, Cameron Simpson wrote: On 22Feb2014 17:56, Ethan Furman et...@stoneleaf.us wrote: Please let me know if anything else needs tweaking. [...] This area of programming is characterized by a mixture of binary data and ASCII compatible segments of text (aka ASCII-encoded

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Nick Coghlan
On 23 February 2014 13:47, Cameron Simpson c...@zip.com.au wrote: On 22Feb2014 17:56, Ethan Furman et...@stoneleaf.us wrote: Please let me know if anything else needs tweaking. [...] This area of programming is characterized by a mixture of binary data and ASCII compatible segments of text

Re: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 2

2014-02-22 Thread Nick Coghlan
Thanks Ethan, this mostly looks excellent. On 23 February 2014 11:56, Ethan Furman et...@stoneleaf.us wrote: ``%a`` will call :func:``ascii()`` on the interpolated value's :func:``repr()``. This is intended as a debugging aid, rather than something that should be used in production.