Result of ``a is b''
Ronald Oussoren
oussoren at cistron.nl
Thu Mar 18 15:22:02 EST 2004
On 18-mrt-04, at 14:14, Axel Boldt wrote:
> afriere at yahoo.co.uk (Asun Friere) wrote
>> axelboldt at yahoo.com (Axel Boldt) wrote
>
>>> Why would anybody ever want to
>>> know whether two strings or tupels are internally stored at the same
>>> location, other than to deduce details of the Python implementation?
>>
>> Most obviously to tell whether they are the same object or not.
>> While this is not an issue with simple strings, have you considered
>> what effect your suggestions would have on classes inheriting from
>> str?
>
> Indeed I have not. Probably because basic built-in strings form a type
> that's not a class and you can't inherit from it.
Yes you can:
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class MyStr(str): pass
...
>>> x = MyStr("hello")
>>> type(x)
<class '__main__.MyStr'>
>>>
More information about the Python-list
mailing list