Re: attaching names to subexpressions

2012-10-29 Thread Neil Cerutti
On 2012-10-28, Devin Jeanpierre wrote: >>> The 'canonical way' >>> while True: >>> line = complex_expression >>> if not line: >>> break >>> do_something_with(line) >>> >>> avoids this problem, but I was never really convinced about the beauty / >>> readbility of this constr

Re: attaching names to subexpressions

2012-10-28 Thread Chris Angelico
On Sun, Oct 28, 2012 at 6:12 PM, F.R. wrote: > > How about: > > line = True > while line: > > line = function(x, y, z) > do something with(line) > > ? That's going to go through the body of the loop with a false line before breaking out. In some situations that's not a problem, bu

Re: attaching names to subexpressions

2012-10-28 Thread F.R.
On 10/28/2012 06:57 AM, Devin Jeanpierre wrote: line = function(x, y, z) >while line: > do something with(line) > line = function(x, y, z) How about: line = True while line: line = function(x, y, z) do something with(line) ? Frederic -- http://mail.python.org/mail

Re: attaching names to subexpressions

2012-10-28 Thread Steven D'Aprano
On Sun, 28 Oct 2012 01:57:45 -0400, Devin Jeanpierre wrote: > We have a problem, and two solutions. Solution 1 has downside A, and > solution 2 has downside B. If he complains about downside A, you say, > well, use solution 2. If he complains about downside B, you say, well, > use solution 1. > >

Re: attaching names to subexpressions

2012-10-27 Thread Chris Angelico
On Sun, Oct 28, 2012 at 4:57 PM, Devin Jeanpierre wrote: > What if he wants to avoid both downsides A and B? What solution does > he use then? He switches to a language whose BDFL is not Steven D'Aprano. :) No offense meant Steven... ChrisA -- http://mail.python.org/mailman/listinfo/python-lis

Re: attaching names to subexpressions

2012-10-27 Thread rusi
On Oct 28, 5:49 am, Steven D'Aprano wrote: > It's sure as hell more beautiful and readable than assignment as an > expression. > > If we are going to judge code on the ability of people to take a quick > glance and immediately understand it, then pretty much nothing but > trivial one-liners will

Re: attaching names to subexpressions

2012-10-27 Thread Gelonida N
On 10/27/2012 04:42 AM, Steve Howell wrote: > I have been reading the thread "while expression feature proposal," > and one of the interesting outcomes of the thread is the idea that > Python could allow you to attach names to subexpressions, much like C > allows. In C you can say something like

attaching names to subexpressions

2012-10-26 Thread Steve Howell
I have been reading the thread "while expression feature proposal," and one of the interesting outcomes of the thread is the idea that Python could allow you to attach names to subexpressions, much like C allows. In C you can say something like this: tax_next_year = (new_salary = salary * (1 +