馃悰 Fix `pyquid.Switcher.get_quid` for Quiddity initialization
see: #17 (closed)
This merge request adds a quiddities
read-only list member attribute on pyquid.Switcher
.
Whenever a pyQuiddity
object is initialized (either from pyquid.Switcher.create
or from the pyquid.Quiddity
class) it is appended to the related pyquid.Switcher
instance within its quiddities
attribute.
Calls to pyquid.Switcher.get_quid(id)
now looks in this list and returns a new reference to the pyQuiddity
object matching the id
argument for further processing.
>>> from pyquid import Switcher
>>> sw = Switcher('quidz')
>>> sw.create('dummy', 'q1')
<Quiddity (1) at 0x7fbf386529f0>
>>> sw.create('dummy', 'q2')
<Quiddity (2) at 0x7f2965f0bf38>
>>> sw.quiddities
[<Quiddity (1) at 0x7fbf386529f0>, <Quiddity (2) at 0x7f2965f0bf38>]
>>> quid = sw.get_quid(1)
>>> quid
<Quiddity (1) at 0x7fbf386529f0>
>>> quid.id()
1
>>> sw.quiddities[0] == quid
True
Edited by OpSocket