Re: [Python-Dev] Py3k: Except clause syntax

2006-03-22 Thread Greg Ewing
Tristan Seligmann wrote: Greg Ewing [EMAIL PROTECTED] [2006-03-21 13:20:53 +1200]: Gareth McCaughan wrote: def f((x0,y0) as p0, (x1,y1) as p1): For maximal utility, this would affect the calling signature of the function, too: it would now have keyword arguments named p0 and p1. I

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-20 Thread skip
Skip There seem to be other places where Python is beginning to require Skip parens even though they aren't strictly necessary to resolve Skip syntactic ambiguity. Guido In the style guide only, I hope. Alex Technically, I believe the first place where this did not apply

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-20 Thread Ron Adam
[EMAIL PROTECTED] wrote: Skip There seem to be other places where Python is beginning to require Skip parens even though they aren't strictly necessary to resolve Skip syntactic ambiguity. Guido In the style guide only, I hope. Alex Technically, I believe the first

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-20 Thread Greg Ewing
Guido van Rossum wrote: In the style guide only, I hope. The parens that are mandatory in a few places *are* necessary to resolve ambiguity. That's not entirely true. My original list comprehension implementation didn't require parens around unpacked loop variables -- Guido added them because

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-20 Thread Greg Ewing
Gareth McCaughan wrote: but wouldn't if be nice if you could say def f((x0,y0) as p0, (x1,y1) as p1): I'm not sure that it would. Currently you can look at a function header and get a picture of its calling signature, but this would clutter it up with implementation details of the

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-19 Thread Guido van Rossum
On 3/18/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The comma and as have different precedence in your proposed except clause than they currently do in the import statement. I think that can lead to confusion. In particular, if someone is used to from foo import bar, baz as flurp I

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-19 Thread Alex Martelli
On Mar 19, 2006, at 7:42 PM, Guido van Rossum wrote: ... There seem to be other places where Python is beginning to require parens even though they aren't strictly necessary to resolve syntactic ambiguity. In the style guide only, I hope. The parens that are mandatory in a few

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-19 Thread Gareth McCaughan
On Friday 2006-03-17 05:04, Alex Martelli wrote: Hmmm, if we allowed '(expr as var)' for generic expr's we'd make a lot of people pining for 'assignment as an expression' very happy, wouldn't we...? I hope not. It looks a lot more like a binding construct than an assigning one. But what

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-18 Thread Wolfgang Langner
Hello, what about: try: something except NameError or OtherError as e: Only a thought. -- bye by Wolfgang ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-18 Thread Greg Ewing
Nick Coghlan wrote: So, as a somewhat novel approach, what about putting the as *before* the list of exceptions types? -1. When you're scanning down a series of except clauses, what you're looking for foremost is the types of exceptions being caught. The bound name is of secondary importance

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-18 Thread Greg Ewing
Wolfgang Langner wrote: try: something except NameError or OtherError as e: I don't see that this really helps anything, since it's no clearer how or and as should bind than it is how , and as should bind. Also it has the disadvantage that except E1 or E2 as e: would *not* be

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-18 Thread skip
Greg On the other hand, in Gregexcept E1, E2 as e: Greg the E1, E2 is just a tuple expression, so it's Greg exactly equivalent to Gregexcept (E1, E2) as e: The comma and as have different precedence in your proposed except clause than they currently do in the

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Michael Hudson
[EMAIL PROTECTED] writes: Greg except type as value: Baptiste except type with value: Can I catch multiple exceptions with a single value in this case? Today, I write: try: foo() except (TypeError, KeyError), msg: print msg Either of the above seem

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Fuzzyman
Michael Hudson wrote: [EMAIL PROTECTED] writes: Greg except type as value: Baptiste except type with value: Can I catch multiple exceptions with a single value in this case? Today, I write: try: foo() except (TypeError, KeyError), msg: print

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread skip
Skip try: Skip foo() Skip except TypeError with msg, KeyError with msg: Skip print msg fuzz Wasn't the proposal : fuzz try: fuzz something fuzz except NameError, OtherError as e: fuzz something... I'm not sure. I only saw SomeError as|with

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Brett Cannon
On 3/16/06, Alex Martelli [EMAIL PROTECTED] wrote: On Mar 16, 2006, at 7:30 PM, Brett Cannon wrote: ... I agree. as is taking on the use of assignment in statements that are not ``=`` and I say we just keep on with that. Plus Greg's above Hmmm, if we allowed '(expr as var)' for

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread John J Lee
On Fri, 17 Mar 2006, [EMAIL PROTECTED] wrote: [...] fuzz Wasn't the proposal : fuzz try: fuzz something fuzz except NameError, OtherError as e: fuzz something... I'm not sure. I only saw SomeError as|with SomeValue. Fuzzyman is right. In your formulation the

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Georg Brandl
Brett Cannon wrote: On 3/17/06, Georg Brandl [EMAIL PROTECTED] wrote: John J Lee wrote: In your formulation the comma binds more tightly than the as keyword. In import statements it's the other way around. That seems like it might be a source of confusion. Perhaps parentheses around

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Brett Cannon
On 3/17/06, Georg Brandl [EMAIL PROTECTED] wrote: Brett Cannon wrote: On 3/17/06, Georg Brandl [EMAIL PROTECTED] wrote: John J Lee wrote: In your formulation the comma binds more tightly than the as keyword. In import statements it's the other way around. That seems like it might

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Nick Coghlan
Oleg Broytmann wrote: On Fri, Mar 17, 2006 at 07:44:51PM +, John J Lee wrote: Perhaps parentheses around the exception list should be mandatory for the 2-or-more exceptions case? except NameError as e: -- fine except (NameError) as e:-- fine except

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-17 Thread Greg Ewing
Georg Brandl wrote: I predict people will come and write except NameError as e, OtherError as f: Then they'll learn very fast not to write that, because they'll get a SyntaxError. Greg ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Nick Coghlan
Greg Ewing wrote: For Py3k, any thoughts on changing the syntax of the except clause from except type, value: to except type as value: so that things like except TypeError, ValueError: will do what is expected? +1 here I actually had a go at figuring how to do this a

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Georg Brandl
Greg Ewing wrote: For Py3k, any thoughts on changing the syntax of the except clause from except type, value: to except type as value: so that things like except TypeError, ValueError: will do what is expected? +1. Fits well with the current use of as. Georg

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Michael Urman
On 3/16/06, Georg Brandl [EMAIL PROTECTED] wrote: +1. Fits well with the current use of as. I like it, but wonder about the false parallels below. My initial reaction is it's not worth worrying about as it's easy to learn as part of the import or except statements, and should do the right thing.

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Baptiste Carvello
Greg Ewing a écrit : except type as value: what about except type with value: a program dies with an error message, not as an error message. ciao, BC ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Russell E. Owen
In article [EMAIL PROTECTED], Greg Ewing [EMAIL PROTECTED] wrote: For Py3k, any thoughts on changing the syntax of the except clause from except type, value: to except type as value: so that things like except TypeError, ValueError: will do what is expected?

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Greg Ewing
Baptiste Carvello wrote: what about except type with value: a program dies with an error message, not as an error message. No. The exception object you're catching *is* the value, not something which *has* a value. I maintain that as is the correct word to use here. Greg

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Terry Reedy
Greg Ewing [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Baptiste Carvello wrote: what about except type with value: a program dies with an error message, not as an error message. No. The exception object you're catching *is* the value, not something which *has* a

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread skip
Greg except type as value: Baptiste except type with value: Can I catch multiple exceptions with a single value in this case? Today, I write: try: foo() except (TypeError, KeyError), msg: print msg Either of the above seem like they'd require me to repeat the

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Brett Cannon
On 3/16/06, Greg Ewing [EMAIL PROTECTED] wrote: Baptiste Carvello wrote: what about except type with value: a program dies with an error message, not as an error message. No. The exception object you're catching *is* the value, not something which *has* a value. I maintain that

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-16 Thread Alex Martelli
On Mar 16, 2006, at 7:30 PM, Brett Cannon wrote: ... I agree. as is taking on the use of assignment in statements that are not ``=`` and I say we just keep on with that. Plus Greg's above Hmmm, if we allowed '(expr as var)' for generic expr's we'd make a lot of people pining for

[Python-Dev] Py3k: Except clause syntax

2006-03-15 Thread Greg Ewing
For Py3k, any thoughts on changing the syntax of the except clause from except type, value: to except type as value: so that things like except TypeError, ValueError: will do what is expected? Greg ___ Python-Dev mailing list

Re: [Python-Dev] Py3k: Except clause syntax

2006-03-15 Thread Guido van Rossum
On 3/15/06, Greg Ewing [EMAIL PROTECTED] wrote: For Py3k, any thoughts on changing the syntax of the except clause from except type, value: to except type as value: so that things like except TypeError, ValueError: will do what is expected? Not a bad idea. The trend seems