Re: 1 or 1/0 doesn't raise an exception

2008-12-15 Thread Grant Edwards
On 2008-12-14, Peter Otten <__pete...@web.de> wrote: > Grant Edwards wrote: > >> Short circuit evaluation of booleans is very common (and has >> been for decades), so I don't know why people would expect >> something else. > > Visual Basic ;) I should have known... -- Grant Edwards

Re: 1 or 1/0 doesn't raise an exception

2008-12-15 Thread Tim Rowe
Unfortunately, bool('Ruby totally pwn3s Python!') > True Using Python is not total protection against buggy programs ;-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2008-12-14, Daniel Fetchinson wrote: Let me just point out that unsuspecting people (like me) might rely on the whole expression to be evaluated and rely on exceptions being raised if needed. Short circuit evaluation of booleans is very common (and has been for dec

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Benjamin Kaplan
On Sun, Dec 14, 2008 at 2:38 AM, Gabriel Genellina wrote: > En Sun, 14 Dec 2008 02:40:10 -0200, Benjamin Kaplan > escribió: > > On Sat, Dec 13, 2008 at 10:49 PM, Daniel Fetchinson < >> fetchin...@googlemail.com> wrote: >> >> >> Is it a feature that >>> >> >>> >> 1 or 1/0 >>> >> >>> >> returns 1

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Peter Otten
Grant Edwards wrote: > Short circuit evaluation of booleans is very common (and has > been for decades), so I don't know why people would expect > something else. Visual Basic ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Mel
Daniel Fetchinson wrote: [ ... ] > Let me just point out that unsuspecting people (like me) might rely on > the whole expression to be evaluated and rely on exceptions being > raised if needed. There are a lot of threads on comp.lang.python that mention beginners' possible reactions to language fe

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread MRAB
Rohannes wrote: 'Dive into Python' has a very memorable and interesting section on the 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 ...

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Grant Edwards
On 2008-12-14, Daniel Fetchinson wrote: > Let me just point out that unsuspecting people (like me) might rely on > the whole expression to be evaluated and rely on exceptions being > raised if needed. Short circuit evaluation of booleans is very common (and has been for decades), so I don't know

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread News123
Hi. r wrote: > These are just the kind of things that make Python so beautiful ;) > Thanks Guido! You shouldn't forget to thank K&R ;-) Shortcutting logical operation shortcuts existed already in C and has been adopted by quite a lot of programming languages. bye N -- http://mail.python.org/

Re: 1 or 1/0 doesn't raise an exception

2008-12-14 Thread Rohannes
'Dive into Python' has a very memorable and interesting section on the 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

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Gabriel Genellina
En Sun, 14 Dec 2008 02:40:10 -0200, Benjamin Kaplan escribió: On Sat, Dec 13, 2008 at 10:49 PM, Daniel Fetchinson < fetchin...@googlemail.com> wrote: >> Is it a feature that >> >> 1 or 1/0 >> >> returns 1 and doesn't raise a ZeroDivisionError? If so, what's the >> rationale? > > http://en.wik

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread r
> Let me just point out that unsuspecting people (like me) might rely on > the whole expression to be evaluated and rely on exceptions being > raised if needed. This happens when people assume something ;) Use a different construct if you want to catch error's, I don't understand how you could not

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Benjamin Kaplan
On Sat, Dec 13, 2008 at 10:49 PM, Daniel Fetchinson < fetchin...@googlemail.com> wrote: > >> Is it a feature that > >> > >> 1 or 1/0 > >> > >> returns 1 and doesn't raise a ZeroDivisionError? If so, what's the > >> rationale? > > > > Yes, it's a feature: > > > > http://en.wikipedia.org/wiki/Short-

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Daniel Fetchinson
>> Is it a feature that >> >> 1 or 1/0 >> >> returns 1 and doesn't raise a ZeroDivisionError? If so, what's the >> rationale? > > Yes, it's a feature: > > http://en.wikipedia.org/wiki/Short-circuit_evaluation > > When you have "True or False", you know it's true by the time > you've got the first p

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Benjamin Kaplan
Not that I'm against promoting Python, but most languages have support for short circuit evaluation. That's why you usually use && and || in C, C++, C# and Java- & and | will always evaluate both sides. Short circuit evaluation is what allows you to write things like "if foo is not None and foo.isT

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread r
These are just the kind of things that make Python so beautiful ;) Thanks Guido! -- http://mail.python.org/mailman/listinfo/python-list

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Tim Chase
Is it a feature that 1 or 1/0 returns 1 and doesn't raise a ZeroDivisionError? If so, what's the rationale? Yes, it's a feature: http://en.wikipedia.org/wiki/Short-circuit_evaluation When you have "True or False", you know it's true by the time you've got the first piece, so there's no need

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Wojciech Muła
"Daniel Fetchinson" wrote: > Is it a feature that > > 1 or 1/0 > > returns 1 and doesn't raise a ZeroDivisionError? If so, what's the rationale? See: http://en.wikipedia.org/wiki/Short-circuit_evaluation -- http://mail.python.org/mailman/listinfo/python-list

1 or 1/0 doesn't raise an exception

2008-12-13 Thread Daniel Fetchinson
Is it a feature that 1 or 1/0 returns 1 and doesn't raise a ZeroDivisionError? If so, what's the rationale? -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list