[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Name self not defined



On Jan 28, 2009, at 4:06 PM, James Paige wrote:
The "or" operator is what they call a "short circuiting" operator. If
the first part is True then the second part is never evaluated. If the
first part is False, then the second part is returned.


Ah, the "or" idiom. Read it as "or else." I learned of this as a perl- ism of particular delight:
open(FILE) or die "Can't open the file!";


perl also has inverted tests:
die "The file is not there!" unless open(FILE);


Not trying to start LANGUAGE WARS here, just pointing out that when the idioms line up with common natural-language idioms, it's peculiarly satisfying.

Interestingly, one rarely sees people use "and" as an idiom. It will execute starting with the left-most statement, and keep going until one of them fails, then stop, executing nothing further. So you could read it as "and then"