Message290
Jython differs from CPython in that it does not allow
the attribute __bases__ to be mutable. The method
__setattr__ in PyClass.java explicitly checks for
__bases__ and throws a TypeError.
The example is contrived, but demonstrates the point:
D:\home\development\src\sourceforge\zxJDBC>python
ActivePython 2.0, build 202 (ActiveState Tool Corp.)
based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32
bit (Intel)] on win32
Type "copyright", "credits" or "license" for more
information.
>>> from UserList import UserList
>>> from UserDict import UserDict
>>> UserList.__bases__
()
>>> UserList.__bases__ += (UserDict,)
>>> UserList.__bases__
(<class UserDict.UserDict at 007D99CC>,)
>>> ^Z
D:\home\development\src\sourceforge\zxJDBC>jython
Jython 2.1a1 on java1.3.0 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> from UserList import UserList
>>> from UserDict import UserDict
>>> UserList.__bases__
()
>>> UserList.__bases__ += (UserDict,)
Traceback (innermost last):
File "<console>", line 1, in ?
TypeError: read-only special attribute: __bases__
>>>
Also, refer to the article:
http://noframes.linuxjournal.com/lj-issues/issue84/4540.html
|
|
Date |
User |
Action |
Args |
2008-02-20 17:16:49 | admin | link | issue409930 messages |
2008-02-20 17:16:49 | admin | create | |
|