[Python-Dev] Can Python implementations reject semantically invalid expressions?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Jul 3 06:42:42 CEST 2010


Craig Citro wrote:

> However, in this particular case, here's a question: *why* would
> someone write "return 1 + '1'"?

They might not intend to execute the code at all -- e.g.
they may want to pass the compiled code to dis() to find
out what bytecode gets generated. Having it refuse to
compile would be annoying in that case.

-- 
Greg


More information about the Python-Dev mailing list