is this a bug?
deblnonospammy at theworld.com
Thu Aug 16 05:09:48 CEST 2001
Hmmm, I am sure there is a simple explanation. From the quickee
variation of you example below, I infer that the Python compiler uses a
dictionary for storing literals, so that only 1 copy is of each unique
literal is kept at compile time. When the same string is built at
run-time in my example, the compiler has already done its job so it has
no way to know the symbol just built is already stored somewhere. This
is pure guesswork, so could one of the gurus post the right answer?
result of a run is:
27432416 27432416 27432416
Skip Montanaro wrote:
> Try this:
> >>> def f():
> ... a = "+="
> ... print a is a
> ... print a is "+="
> >>> f()
> It is left as an exercise for the reader why the result of executing f()
> produces different results than the previous interactive session. ;-)
> Skip Montanaro (skip at pobox.com)
More information about the Python-list