Message215191
Specifically the example at: https://docs.python.org/3/library/functools.html?highlight=functools#functools.partialmethod
``_alive`` isn't actually assigned before the example tries to read it. Running this code at a for-real REPL results in:
>>> class Cell(object):
... @property
... def alive(self):
... return self._alive
... def set_state(self, state):
... self._alive = bool(state)
... import functools
... set_alive = functools.partialmethod(set_state, True)
... set_dead = functools.partialmethod(set_state, False)
...
>>> c = Cell()
>>> c.alive
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in alive
AttributeError: 'Cell' object has no attribute '_alive' |
|
Date |
User |
Action |
Args |
2014-03-30 18:15:13 | alex | set | recipients:
+ alex, docs@python |
2014-03-30 18:15:13 | alex | set | messageid: <1396203313.39.0.663002564911.issue21105@psf.upfronthosting.co.za> |
2014-03-30 18:15:13 | alex | link | issue21105 messages |
2014-03-30 18:15:12 | alex | create | |
|