Re: 1 or 1/0 doesn't raise an exception
- From: MRAB <google@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 14 Dec 2008 15:43:46 +0000
Rohannes wrote:
'Dive into Python' has a very memorable and interesting section on theJava has a bool type that's distinct from the int type. &, | and ^ are bitwise for int and Boolean for bool, and in both cases they are strict. && and || are for bool only and they are lazy.
exact behaviour of 'and' and 'or' in Python:
http://diveintopython.org/power_of_introspection/and_or.html
No: &, | (and ^, too) perform bitwise operations in Python, C and Java:
"In complete evaluation ... both expressions are always evaluated. To
obtain complete evaluation in Java, you use & rather than && ... and
use | in place of ||" - Walter Savitch, Absolute Java 2nd ed.
Although & IS the bitwise-AND operator in Java:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
I guess it's a matter of context.
In Pascal the behaviour of "and" and "or" is implementation-dependant...
.
- References:
- Re: 1 or 1/0 doesn't raise an exception
- From: Gabriel Genellina
- Re: 1 or 1/0 doesn't raise an exception
- From: Rohannes
- Re: 1 or 1/0 doesn't raise an exception
- Prev by Date: Re: 1 or 1/0 doesn't raise an exception
- Next by Date: Re: 1 or 1/0 doesn't raise an exception
- Previous by thread: Re: 1 or 1/0 doesn't raise an exception
- Next by thread: Error with SOAPpy
- Index(es):
Relevant Pages
|