Life's better without builtins? (was: Life's better without braces)

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Feb 25 14:05:32 EST 2000


Niels Diepeveen <niels at endea.demon.nl> writes:

> I think you're a bit pessimistic there. For example:
> 
> _interns = {}
> 
> def intern(s):
>     try:
>         return _interns[s]
>     except KeyError:
>         _interns[s] = s
>         return s

That doesn't work:

>>> x="foo"
>>> x is "fo"+"o"
0
>>> x is intern("fo"+"o")
1

won't work with your version of intern.

Regards,
Martin



More information about the Python-list mailing list