global name 'self' is not defined - noob trying to learn

mark.seagoe at gmail.com mark.seagoe at gmail.com
Mon Mar 30 10:04:23 EDT 2009


On Mar 30, 2:30 am, Jan Decaluwe <j... at jandecaluwe.com> wrote:
> mark.sea... at gmail.com wrote:
> > Python 2.5.3 for business reasons.
>
> > So I want a class ShadowRegister, which just has a value that I can do
> > get/set bit sel and slice ops.  I got that working with __init__.  It
> > was subclass from "object".  Then I wanted a RegisterClass that was a
> > subclass of ShadowRegister, which would read a hardware register
> > before doing get bit sel/slices, or read HW reg, do set bit sel/slice,
> > but when I try to print in hex format ('0x016X') it said it required
> > an int (but the ShadowRegister class had no issues).  Then I was told
> > instead of using object I could subclass as long (seemed the only
> > solution for Python 2.5).  Then when I started to want to add my own
> > init code (like register length in bits), I was told I should use
> > __new__ instead of __init__.  So but ever since then I've noticed that
> > my value is not changing from the initially set value.  I'm really
> > cornfused now.
>
> In the past, someone referred you to the intbv class in MyHDL.
> You mentioned that it does "more than you want".
> However, it seems to me that what intbv really does, is to solve
> the kind of issues that you are struggling with. Perhaps
> you want to look at it again.
>
> Jan
>
> --
> Jan Decaluwe - Resources bvba -http://www.jandecaluwe.com
>     Python as an HDL:http://www.myhdl.org
>     VHDL development, the modern way:http://www.sigasi.com
>     Analog design automation:http://www.mephisto-da.com
>     World-class digital design:http://www.easics.com- Hide quoted text -
>
> - Show quoted text -

Hi Hrvoje, Jan;

This is about what I actually originally had, it was derived from
"object", like the intbv class from MyHDL.  And so my ShadowRegister
class was modeled similar to that.  It worked grea.  Then ChipRegister
was made to be a subclass of ShadowRegister.  It needs to read HW reg
and adjust ChipRegister value, write HW reg and adjust ShadowRegister
value.  As mentioned, that's when printing in hex gave an error said
it needed an int.  My story from that point continues from my last
past.  :)




More information about the Python-list mailing list