Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 06:41 PM, Terry Reedy wrote: On 10/10/2013 9:33 AM, Ethan Furman wrote: On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: first_element = some_list[0]# Oops, may crash some_list[0:1] always works, and sometimes is usable, but you st

Re: Python's and and Pythons or

2013-10-10 Thread Terry Reedy
On 10/10/2013 9:33 AM, Ethan Furman wrote: On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: first_element = some_list[0]# Oops, may crash some_list[0:1] always works, and sometimes is usable, but you still cannot index the slice. Not if some_l

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like A bit awkward, echo-argument or is more naturally useful to

Re: Python's and and Pythons or

2013-10-10 Thread Chris Angelico
On Thu, Oct 10, 2013 at 6:43 PM, Terry Reedy wrote: > y = x and 1/x > One just has to remember that y==0 effectively means y==+-infinity ;-). Good example. Extremely appropriate to situations where you're showing a set of figures and their average: Foo 1 Bar 3 Quux 7 Asdf 9 = 5 Let th

Re: Python's and and Pythons or

2013-10-10 Thread Terry Reedy
On 10/10/2013 2:45 AM, Chris Angelico wrote: On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like A bit awkward, echo-argument or is more naturally useful to me then echo-argument and. first_element

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/09/2013 11:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like possible = foo and foo.allowsit() if (possible is None) : print "foo not provided" if (possible is False) : print "foo doesn't allow it" A bit awkward,

Re: Python's and and Pythons or

2013-10-10 Thread Peter Cacioppi
On Wednesday, October 9, 2013 4:54:03 PM UTC-7, Peter Cacioppi wrote: > I really like the logic that Pythons "or" is not only short-circuit but > non-typed. > > > > So I can say > > > > y = override or default > > > > and y won't necc be True or False. If override boolean evaluates to Tru

Re: Python's and and Pythons or

2013-10-09 Thread Chris Angelico
On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: > I'm trying to think of a good example usage of echo-argument and. Maybe > something like > > possible = foo and foo.allowsit() > if (possible is None) : >print "foo not provided" > if (possible is False) : >print "foo doesn't allow

Re: Python's and and Pythons or

2013-10-09 Thread Peter Cacioppi
On Wednesday, October 9, 2013 4:54:03 PM UTC-7, Peter Cacioppi wrote: > I really like the logic that Pythons "or" is not only short-circuit but > non-typed. > > > > So I can say > > > > y = override or default > > > > and y won't necc be True or False. If override boolean evaluates to Tru

Re: Python's and and Pythons or

2013-10-09 Thread Chris Angelico
On Thu, Oct 10, 2013 at 11:36 AM, Steven D'Aprano wrote: > Other languages (Ruby, PHP, Javascript, etc.) also have > truthy and falsey values, but in my opinion none of them have got it > right. Python has a unifying model of truthiness: objects which represent > "something" ought to be truthy, th

Re: Python's and and Pythons or

2013-10-09 Thread Steven D'Aprano
On Wed, 09 Oct 2013 16:54:03 -0700, Peter Cacioppi wrote: > I really like the logic that Pythons "or" is not only short-circuit but > non-typed. > > So I can say > > y = override or default > > and y won't necc be True or False. If override boolean evaluates to True > (which, for most classes,

Python's and and Pythons or

2013-10-09 Thread Peter Cacioppi
I really like the logic that Pythons "or" is not only short-circuit but non-typed. So I can say y = override or default and y won't necc be True or False. If override boolean evaluates to True (which, for most classes, means not None) than y will be equal to override. Otherwise it will be equ