Jython class names

Peter Otten __peter__ at web.de
Tue Sep 9 16:43:42 CEST 2003


Robin Becker wrote:

> C:\jython-2.1>jython
> Jython 2.1 on java1.4.2 (JIT: null)
> Type "copyright", "credits" or "license" for more information.
>>>> class C: pass
> ...
>>>> C().__class__.__name__ is C.__name__
> 0
>>>> C().__class__.__name__ == C.__name__
> 1
>>>>

That's definitely not what I expected. So == is the way to go.
Still, I'm curious: would the code below return 100 in Jython?

>>> class C: pass
...
>>> many = [C() for i in range(100)]
>>> d = {}
>>> for c in many:
...     d[id(c.__class__.__name__)] = None
...
>>> len(d.keys())
1

Peter




More information about the Python-list mailing list