Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-12 Thread Alan Gauld
"Steven D'Aprano" wrote Spiced tea with milk. Well, technically, it just means "tea with milk", but in English chai is used exclusively for spiced tea Never heard of it I confess. I've heard the, presumably related, term char, meaning a cup of black tea (as in tea without milk, not black l

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-12 Thread Steven D'Aprano
Alan Gauld wrote: "Steven D'Aprano" wrote ordered a chai latte at a cafe. The waiter had no idea what that was, but must have known that "chai" means tea, and so mixed tea and coffee So now I've got to ask, what is a chai latte? I could Google it but I'm feeling lazy :-) Spiced tea with m

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-12 Thread Alan Gauld
"Steven D'Aprano" wrote ordered a chai latte at a cafe. The waiter had no idea what that was, but must have known that "chai" means tea, and so mixed tea and coffee So now I've got to ask, what is a chai latte? I could Google it but I'm feeling lazy :-) Alan G.

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-11 Thread Steven D'Aprano
Lie Ryan wrote: The question "Would you like Italian or Chinese for dinner" is actually a contraction of "Would you like Italian for dinner or would you like Chinese for dinner". If we ask these two questions separately to the wife, we get either "Yes or Yes", "Yes or No", "No or Yes", or "No or

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-11 Thread Lie Ryan
On 12/11/10 04:12, Alan Gauld wrote: > "Steven D'Aprano" wrote >> As an experiment, offer to buy your wife dinner, and ask if she'd >> prefer to go to an Italian or Chinese restaurant. > > :-) > She would either answer "Yes" (she would like to go to one of > them, and if I'm lucky she might give

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-10 Thread Walter Prins
Hi Steven On 10 December 2010 03:50, Steven D'Aprano wrote: > Some languages (Pascal comes to mind) doesn't have short-circuit behaviour > at all. > Don't mean to nit pick, but in my experience it really depends on the compiler implementation and which version of Pascal you're talking about. Ce

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-10 Thread Alan Gauld
"Steven D'Aprano" wrote Python knows that if val is true then it doesn't need to evaluate the second term that causes it to return val rather than 1. That's what makes it short circuiting, but that's not why it returns the first argument. `or` in standard Pascal doesn't short-circuit. But

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-10 Thread Steven D'Aprano
ALAN GAULD wrote: Doesn't short-circuit evaluation refer specifically to the behavior where arguments are only evaluated if they need to be? It's a very useful feature, but not technically required for the "val = val or 1" behavior to work. Its essential. If Python always evaluated all par

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-10 Thread ALAN GAULD
> Doesn't short-circuit evaluation refer specifically to the behavior > where arguments are only evaluated if they need to be? It's a very > useful feature, but not technically required for the "val = val or 1" > behavior to work. Its essential. If Python always evaluated all parts of a boole

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Steven D'Aprano
Hugo Arts wrote: Doesn't short-circuit evaluation refer specifically to the behavior where arguments are only evaluated if they need to be? It's a very useful feature, but not technically required for the "val = val or 1" behavior to work. Yes, exactly. Some languages (Pascal comes to mind) d

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Hugo Arts
On Fri, Dec 10, 2010 at 2:07 AM, Alan Gauld wrote: > > "Alex Hall" wrote >> >> val=val or 1 > >> I am guessing that val is an int. If val==0, the 'or' kicks in and >> val=1, else the or is not needed and val=val. Am I close? > > Yes this is a combination of what is known as short circuit evaluati

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Thanks to all for the quick responses. Python always surprises me with its shortcuts... On 12/9/10, Alan Gauld wrote: > > "Alex Hall" wrote > >> val=val or 1 > >> I am guessing that val is an int. If val==0, the 'or' kicks in and >> val=1, else the or is not needed and val=val. Am I close? > > Y

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alan Gauld
"Alex Hall" wrote val=val or 1 I am guessing that val is an int. If val==0, the 'or' kicks in and val=1, else the or is not needed and val=val. Am I close? Yes this is a combination of what is known as short circuit evaluation of boolean expressions and a quirk of Python that returns

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Adam Bark
On 10/12/10 00:51, Alex Hall wrote: Hi all, I am reading the source of a project I hope to help with (http://www.qwitter-client.net). I sometimes see something like: val=val or 1 I am guessing that val is an int. If val==0, the 'or' kicks in and val=1, else the or is not needed and val=val. Am I

[Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Alex Hall
Hi all, I am reading the source of a project I hope to help with (http://www.qwitter-client.net). I sometimes see something like: val=val or 1 I am guessing that val is an int. If val==0, the 'or' kicks in and val=1, else the or is not needed and val=val. Am I close? Can other words or symbols be u

Re: [Tutor] or synxtax in if statement

2007-08-31 Thread Brian Wisti
On 8/31/07, David Bear <[EMAIL PROTECTED]> wrote: > > I think I want to be lazy and express this > > if a == b | a = c > (if a equal b or a equals c) > using > > if a == b | c > > it seems to work.. but I'm not sure if it is correct -- and I haven't seen > any documentation on using this type of sy

Re: [Tutor] or synxtax in if statement

2007-08-31 Thread Eric Brunson
David Bear wrote: > I think I want to be lazy and express this > > if a == b | a = c > (if a equal b or a equals c) > using > > if a == b | c > > it seems to work.. but I'm not sure if it is correct -- and I haven't seen > any documentation on using this type of syntax. > > > The pipe is the "bi

Re: [Tutor] or synxtax in if statement

2007-08-31 Thread Smith, Jeff
t; c=0 >>> print a == b or c 0 Which is the same as false. Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Bear Sent: Friday, August 31, 2007 3:40 PM To: tutor@python.org Subject: [Tutor] or synxtax in if statement I think I want

[Tutor] or synxtax in if statement

2007-08-31 Thread David Bear
I think I want to be lazy and express this if a == b | a = c (if a equal b or a equals c) using if a == b | c it seems to work.. but I'm not sure if it is correct -- and I haven't seen any documentation on using this type of syntax. -- -- David Bear College of Public Programs at Arizona State

Re: [Tutor] or

2007-03-29 Thread John Fouhy
On 30/03/07, Christopher Spears <[EMAIL PROTECTED]> wrote: > What I can't remember is what is 'or' in python. For > example, what if I want the loop to skip apples and > pears? I tried this: > > >>> for f in fruit: > ... if f != "apples" or "pears": > ... print f > ...

[Tutor] or

2007-03-29 Thread Christopher Spears
I was doodling at the interpreter: >>> fruit = ["apples","pears","oranges"] >>> for f in fruit: ... if f != "apples": ... print f ... print "This is not an apple." ... pears This is not an apple. oranges This is not an apple. What I can't remember is what is 'or' in py

Re: [Tutor] OR operator?

2006-04-06 Thread Alan Gauld
> I'm trying with this operator, could it possible? > > fruit1 = 'apple' > fruit2 = 'orange' > > fruits = fruit1 or fruit2 > > is 'orange' = fruits ? Why not just try it at the python prompt?! And you would find that no, fruits = 'apple' (The order is because fruits is a name which references

Re: [Tutor] OR operator?

2006-04-05 Thread Charles Bartley
> > I'm trying with this operator, could it possible? > > fruit1 = 'apple' > fruit2 = 'orange' > > fruits = fruit1 or fruit2 > > is 'orange' = fruits ? Maybe this: ### fruit1 = 'apple' fruit2 = 'orange' fruits = [fruit1, fruit2] print 'orange' in fruits# prints the boolean result of 'o

[Tutor] OR operator?

2006-04-05 Thread ទិត្យវិរៈ
Hi, I'm trying with this operator, could it possible? fruit1 = 'apple' fruit2 = 'orange' fruits = fruit1 or fruit2 is 'orange' = fruits ? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor