Re: condition and True or False

2010-05-06 Thread Lawrence D'Oliveiro
In message <685761fe-b052-4d89-92d3-17d1f2a39...@p2g2000yqh.googlegroups.com>, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > > x = and True or False I suspect the

Re: condition and True or False

2010-05-02 Thread John Machin
On May 3, 9:14 am, Steven D'Aprano wrote: > If it is any arbitrary object, then "x and True or False" is just an > obfuscated way of writing "bool(x)". Perhaps their code predates the > introduction of bools, and they have defined global constants True and > False but not bool. Then they removed

Re: condition and True or False

2010-05-02 Thread Patrick Maupin
On May 2, 12:14 pm, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >     x = and True or False > > What is "and True or False" adding to this picture?  The boolean > expr

Re: condition and True or False

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 10:14:44 -0700, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code that > might better be coded using "y if x else z", I came across this puzzler: > > x = and True or False > > What is "and True or False" adding to this picture? Th

Re: condition and True or False

2010-05-02 Thread Carl Banks
On May 2, 10:14 am, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >     x = and True or False > > What is "and True or False" adding to this picture?  The boolean > expr

Re: condition and True or False

2010-05-02 Thread David Robinow
On Sun, May 2, 2010 at 1:14 PM, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >    x = and True or False > > What is "and True or False" adding to this picture?  The boo

Re: condition and True or False

2010-05-02 Thread Vito 'ZeD' De Tullio
Peter Otten wrote: > def f(): > big_beast = list(range(10**100)) > return big_beast and True or False > x = f() > > it would prevent that a big_beast reference becomes visible outside the > function and allow for immediate release of its memory. what's wrong in bool(big_beast)? -- By Z

Re: condition and True or False

2010-05-02 Thread Peter Otten
Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > > x = and True or False > > What is "and True or False" adding to this picture? The boolean > expression part is alr

condition and True or False

2010-05-02 Thread Paul McGuire
While sifting through some code looking for old "x and y or z" code that might better be coded using "y if x else z", I came across this puzzler: x = and True or False What is "and True or False" adding to this picture? The boolean expression part is already evaluating to a boolean, so I do