[Python-Dev] Can Python implementations reject semantically invalid expressions? (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Fri Jul 2 19:28:44 CEST 2010
- Previous message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Next message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jul 3, 2010 at 3:13 AM, Craig Citro <craigcitro at gmail.com> wrote:
"1/0" is much faster to type than "raise SomeError" and serves the same purpose sometimes for debugging purposes. Let's not forget that not all code is written for eternity :)
Doesn't "raise" do the same thing for just two extra characters?
No, raise on its own is only valid in an exception handler. Writing "1/0" is at least somewhat common as an idiom for forcing a ZeroDivisionError in examples and in test harnesses (I know I have used it for both of those things many times).
Given the diverse range of uses Python is put to, moving things from runtime to compile time can definitely have significant unexpected consequences (hence why many of us would be hesitant to consider an implementation that made such changes to be an actual Python implementation).
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Next message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]