exceptions with spaces don't work??
Greg Ewing (using news.cis.dfn.de)
ckea25d02 at sneakemail.com
Tue Apr 8 06:55:04 CEST 2003
John J Lee wrote:
> Maybe it happens to work sometimes because Python is caching
> short strings, so the two occurrences of "someerror" happen to be the same
> object in memory.
Essentially, yes. The caching is known as "interning" (a term
which goes back to the early days of Lisp). The bytecode
compiler interns any string literals which happen to resemble
Python identifiers (because this speeds lookup of names at
Putting spaces in the string is one way to make it
not look like an identifier, so it doesn't get interned.
There are many other ways, of course.
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
More information about the Python-list