Re: python3: accessing the result of 'if'

2005-01-10 Thread Nick Coghlan
Steve Holden wrote: Excuse me, these are supposed to be IMPROVEMENTS to Python? I think it's more messing around before coming to the conclusion that, of the many things that 'where' helps with, this sure as hell ain't one of them :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Bri

Re: python3: accessing the result of 'if'

2005-01-09 Thread Bengt Richter
On Sat, 08 Jan 2005 18:30:25 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: >Carl Banks wrote: >> Right. But you know that as soon as you add this to simple >> expressions, a bunch of people are going to come here whining about how >> they don't get to use where with if-expressions. So why should

Re: python3: accessing the result of 'if'

2005-01-09 Thread Steve Holden
Nick Coghlan wrote: Carl Banks wrote: What if the condition you wanted to test wasn't the same as the thing you want to save? In other words, how would you convert this? . where: . m = something() . if m > 20: . do_something_with(m) Yeah, this problem eventually occurred to me as well. Ho

Re: python3: accessing the result of 'if'

2005-01-09 Thread Andrey Tatarinov
Carl Banks wrote: As a compromise, howabout: . if m > 20 where m=something(): . do_something_with(m) That's good, but first idea was about 'where' block that contains any expressions, that we need, for example function definition. the syntax you proposed has same problems as 'lambda'. The ma

Re: python3: accessing the result of 'if'

2005-01-08 Thread Carl Banks
Donn Cave wrote: > If Python 3 is going to get assignment-as-expression, it will be > because GvR accepts that as a reasonable idea. You won't bootleg it > in by trying to hide it behind this "where" notion, and you're not > doing "where" any good in trying to twist it this way either. I suspect

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
Carl Banks wrote: I'm sorry, I really can't agree that this helper function "solves" it. IMO, it's a workaround, not a solution. And, if I may be frank, it's a pretty ugly one. Heck, I thought it was ugly and I wrote it :) So in reality, I'd continue to use the nested-if approach that works right

Re: python3: accessing the result of 'if'

2005-01-08 Thread Donn Cave
Quoth "Carl Banks" <[EMAIL PROTECTED]>: ... | As a compromise, howabout: | | . if m > 20 where m=something(): | . do_something_with(m) | | In this case, the m=something() is NOT an assignment statement, but | merely a syntax resembling it. The "where m=something()" is part of | the if-statemen

Re: python3: accessing the result of 'if'

2005-01-08 Thread Carl Banks
Nick Coghlan wrote: > Carl Banks wrote: > > What if the condition you wanted to test wasn't the same as the thing > > you want to save? In other words, how would you convert this? > > > > . where: > > . m = something() > > . if m > 20: > > . do_something_with(m) > > Yeah, this problem even

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
Carl Banks wrote: What if the condition you wanted to test wasn't the same as the thing you want to save? In other words, how would you convert this? . where: . m = something() . if m > 20: . do_something_with(m) Yeah, this problem eventually occurred to me as well. However, I think a litt

Re: python3: accessing the result of 'if'

2005-01-08 Thread Carl Banks
Nick Coghlan wrote: > I have a different suggestion for this. > > 'as' is used for renaming in import statements. 'as' will be used for exception > naming in Python 3k. > > So let's use it for expression naming in 'if' statements, too. > > if someregexp.match(s) as m: ># blah using m > elif som

Re: python3: accessing the result of 'if'

2005-01-08 Thread Paul Rubin
Nick Coghlan <[EMAIL PROTECTED]> writes: > So let's use it for expression naming in 'if' statements, too. > > if someregexp.match(s) as m: ># blah using m > elif someotherregexp.match(s) as m: ># blah using m Certainly an improvement over what we have now. -- http://mail.python.org/mailm

Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
Carl Banks wrote: Right. But you know that as soon as you add this to simple expressions, a bunch of people are going to come here whining about how they don't get to use where with if-expressions. Frankly, they might have a point here. Although we have replacing lambda expressions on our minds,