Message1008
You can't correctly subclass str in 2.2a1. Instances of
the subclass are actually strings. Here is a simple
example:
>>> class p(str):
... def foo(self):
... print 'I am a p'
...
>>> s=p('bar')
>>> s
'bar'
>>> s.foo()
Traceback (innermost last):
File "<console>", line 1, in ?
AttributeError: 'string' object has no attribute 'foo'
>>> type(s)
<type 'str'>
In Python 2.4.1 I get:
>>> class p(str):
... def foo(self):
... print 'I am a p'
...
>>> s = p('bar')
>>> s
'bar'
>>> s.foo()
I am a p
>>> type(s)
<class '__main__.p'>
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:23 | admin | link | issue1243049 messages |
2008-02-20 17:17:23 | admin | create | |
|