RE: Python: What Happens When This If Executes?

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 3 Nov 2010 10:27:34 -0400

Hi Jim,
Is the code execution more efficient when writing it like this?

Thanks.

Jim

Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Internal recipients,  Read my accessibility 
blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. Discuss 
accessibility 
here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. 
Accessibility Wiki: Breaking news and accessibility 
advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx>

From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jim Dunleavy
Sent: Wednesday, November 03, 2010 7:11 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Python: What Happens When This If Executes?

Hi Jim,

The feature is called comparison chaining and is equivalent to
if board[row[0]] == board[row[1]] and board[row[1]] == board[row[2]] and
  board[row[2]] != EMPTY:
except that the operands are only evaluated once.
It's covered in chapter 5 Expressions, of the Python reference.

--Jim


----- Original Message -----
From: Homme, James<mailto:james.homme@xxxxxxxxxxxx>
To: programmingblind@xxxxxxxxxxxxx<mailto:programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, November 02, 2010 2:42 PM
Subject: Python: What Happens When This If Executes?

Hi,
I understand that this statement compares three values to see if they are the 
same, and that they are not the value called Empty, which is a global variable 
filled with a space, but how does it do this?

if board[row[0]] == board[row[1]] == board[row[2]] != EMPTY:

Thanks.

Jim

Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Internal recipients,  Read my accessibility 
blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. Discuss 
accessibility 
here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. 
Accessibility Wiki: Breaking news and accessibility 
advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx>


________________________________
This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed. If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.








________________________________






"Tá an fhaisnéis sa ríomhphost seo (ceangaltáin san áireamh) faoi rún.

Baineann sé leis an té ar seoladh chuige  amháin agus tá sé ar intinn go

bhfaighfidh siadsan amháin é agus gurb iadsan amháin a dhéanfaidh breithniú

air. Más rud é nach tusa an duine ar leis é, tá cosc iomlán ar aon fhaisnéis

atá ann, a úsáid, a chraobhscaoileadh, a scaipeadh, a nochtadh, a fhoilsiú, ná

a chóipeáil . Seains gurb iad tuairimí pearsanta an údar atá san ríomhphost

agus nach tuairimí FSS iad.



Má fuair tú an ríomhphost seo trí dhearmad, bheadh muid buíoch dá gcuirfeá in

iúil don Deasc Seirbhísí ECT ar an nguthán ag +353 1 6352757  nó ar an

ríomhphost chuig service.desk@xxxxxx agus ansin glan an ríomhphost seo ded'

chóras."



"Information in this email (including attachments) is confidential.

It is intended for receipt and consideration only by the intended recipient.

If you are not an addressee or intended recipient, any use, dissemination,

distribution, disclosure, publication or copying of information contained in

this email is strictly prohibited.  Opinions expressed in this email may be

personal to the author and are not necessarily the opinions of the HSE.



If this email has been received by you in error we would be grateful if you

could immediately notify the ICT Service Desk by telephone at +353 1 6352757

or by email to service.desk@xxxxxx and thereafter delete this

e-mail from your system"




________________________________







Other related posts: