what does is ?
Gerhard Häring
gerhard.haering at opus-gmbh.net
Wed Nov 27 06:55:08 EST 2002
Jonas Geiregat <kemu at sdf-eu.org> wrote:
> I saw something
> import string
> string._StringType is str
> what does this specially that IS
The "is" operator compares object *identity*, rather than equality, which the
"==" operator does.
> or in 2.2.2 string._StringTypes is str
I'd assume the check "types.StringType is str" will check if you have a Python
implementation (CPython or Jython) with class-type unification:
In pre-2.2 versions of CPython, str was a built-in function, while in 2.2+, it
is a new-style class:
C:\>c:\Python21\python.exe
Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import types
>>> str, types.StringType
(<built-in function str>, <type 'string'>)
>>>
C:\>c:\Python22\python.exe
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> str, types.StringType
(<type 'str'>, <type 'str'>)
>>> str is types.StringType
1
--
Gerhard Häring
OPUS GmbH München
Tel.: +49 89 - 889 49 7 - 32
http://www.opus-gmbh.net/
More information about the Python-list
mailing list