Message295037
Actually the docs says "This attribute is available when using the buffered I/O classes from the io module", which means it's not always available since it depends on an inner field set or not.
It's just like Python code:
>>> class CW:
... def __get__(self, obj, objtype):
... if obj._written:
... return obj._written
... else:
... raise AttributeError("characters_written")
... def __set__(self, obj, val):
... obj._written = val
...
>>> class MyOSError:
... characters_written = CW()
... def __init__(self):
... self._written = False
...
>>> dir(MyOSError())
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_written', 'characters_written']
>>> MyOSError().characters_written
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in __get__
AttributeError: characters_written |
|
Date |
User |
Action |
Args |
2017-06-02 16:44:50 | xiang.zhang | set | recipients:
+ xiang.zhang, Igor Kozyrenko (ikseek) |
2017-06-02 16:44:50 | xiang.zhang | set | messageid: <1496421890.29.0.106818852135.issue30554@psf.upfronthosting.co.za> |
2017-06-02 16:44:50 | xiang.zhang | link | issue30554 messages |
2017-06-02 16:44:49 | xiang.zhang | create | |
|