[myhdl-list] Re: VCD viewer ?
Brought to you by:
jandecaluwe
From: Jean D. <jea...@un...> - 2005-04-26 16:06:01
|
Jan Decaluwe a écrit : > Jean Demartini wrote: > >> I'm a little newbie in Python and some Python idiom's are a little >> puzzling. Then my question: >> >> Why an enum variable is not a true class testable by >> isinstance(..,Enum) ? this will simplify the catching of enum >> variables in _Signal.py. >> >> Jean > > > I see your point, and I agree. > > Probably the "idiom" that puzzles you is the usage of the "nested" > classes EnumItem and Enum in function enum in module _enum.py. > This looks rather strange: my intention was to make sure these > auxiliary classes are not directly usable by a user. But there > are other ways to achieve that, such as giving them a "private" > name, starting with underscore. > > You are correct in stating that these objects should be > indentifiable by an instance check. This can be achieved easily > by using a "dummy" parent class, whose sole purpose is to be > subclassable by the actual (private) Enum class. This can be > done as follows (untested): > > In _enum.py, create a new EnumType class at the module level: > > class EnumType(object): > pass > > Subclass the private Enum class from EnumType instead of object: > > class Enum(EnumType): > .... > > Make the EnumType class visible in __init__.py: > > from _enum import EnumType > > Now you can use it with: > > from myhdl import EnumType > > and things like isinstance(obj, EnumType) should work. > > Regards, > > Jan > Thanks for all this information. I will modify _Signal.py and _traceSignals.py accordingly trying to maintain compatibility between GTKwave and WaveVCD. I will then inform the forum of the progress. Jean |