On 9/11/11 4:06 PM, Sébastien Bourdeauducq wrote:
> Hi,
>
> why isn't it possible to use __dict__ on signal objects? How to get
> equivalent functionality?
>
> Thanks,
> Sébastien
>
> >>> from myhdl import *
> >>>
> >>> s = Signal(intbv(0)[5:])
> >>>
> >>> print s._max
> 32
> >>> print s.__dict__["_max"]
> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> File "/home/lekernel/TE/myhdl/myhdl/_Signal.py", line 465, in __getattr__
> return getattr(self._val, attr)
> AttributeError: 'intbv' object has no attribute '__dict__'
>
You can see from the error message, the __dict__ on a Signal, simply
tries to pass the attribute *get* to whatever the Signal might be
containing. It does work on an object that does have a __dict__ but the
intbv doesn't have a __dict__.
class foo(object):
....: def __init__(self):
....: pass
....:
....:
In [78]: x = foo()
In [79]: x.bar = 1
In [81]: xs = Signal(x)
In [83]: xs.__dict__
Out[83]: {'bar': 1}
Regards,
Chris Felton
|