Jython class names

Erik Max Francis max at alcyone.com
Tue Sep 9 04:07:41 EDT 2003


Robin Becker wrote:

> I recently came across a problem with porting to Jython
> 
> basically the following is prints 1 in CPython, but not in Jython.
> 
> class C:
>         pass
> 
> red = C()
> print red.__class__.__name__ is 'C'
> 
> it seems that Jython doesn't intern names in the same way or instances
> are not constructed in the same way. Is the above test robust or
> should
> I always be using == for testing class names?

You should be testing string equality with ==.  Whether two strings that
are equal are actually the same string (is) is an implementation detail.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ I sidestep the either/.or choices of logic and choose both.
\__/  Ken Feit




More information about the Python-list mailing list