Creating a List of Empty Lists
Skip Montanaro
skip at pobox.com
Sat Dec 6 15:13:08 EST 2003
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
>>> b = intern('foo bar')
>>> a = 'foo bar'
>>> a is 'foo bar'
False
>>> b is 'foo bar'
False
Emile> That apparent space requirement should really be better documented.
The fact that the current implementation of CPython automatically interns
strings which look like identifiers is simply an efficiency consideration.
It's not part of the language definition, so doesn't bear documenting. The
correct way to compare two strings is using '==' (which is independent of
CPython's implementation details), not 'is'.
Skip
More information about the Python-list
mailing list