On Nov 24, 6:38 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> samwyse <[EMAIL PROTECTED]> writes:
> > create a hash that maps your keys to themselves, then use the values
> > of that hash as your keys.
>
> The "atom" function you describe already exists under the name
> "intern".
D'oh! That's what I get for not memorizing "Non-essential Built-in
Functions".
In my defense, however, my function will work with anything that can
be used as a dictionary key (strings, tuples, frozen sets, etc), not
just character strings; thus we return to the original:
>>> a=(1,2,3)
>>> b=(1,1+1,1+1+1)
>>> a == b
True
>>> a is b
False
>>> atom(a) is atom(b)
True
>>> intern(a) is intern(b)
Traceback (most recent call last):
File "<pyshell#33>", line 1, in ?
intern(a) is intern(b)
TypeError: intern() argument 1 must be string, not tuple
--
http://mail.python.org/mailman/listinfo/python-list