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

2009-03-30 Thread Scott David Daniels
mark.sea...@gmail.com wrote: On Mar 29, 9:52 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 29, 2009 at 9:18 PM, mark.sea...@gmail.com wrote: ... ... Also, you shouldn't use `class_ ` as the name of the first argument to __new__(). Use `cls` instead since that's the conventional name

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

2009-03-30 Thread Chris Rebert
2009/3/29 Scott David Daniels scott.dani...@acm.org: mark.sea...@gmail.com wrote: On Mar 29, 9:52 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 29, 2009 at 9:18 PM,  mark.sea...@gmail.com wrote: ... ... Also, you shouldn't use `class_ ` as the name of the first argument to

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

2009-03-30 Thread mark . seagoe
On Mar 29, 11:16 pm, Chris Rebert c...@rebertia.com wrote: 2009/3/29 Scott David Daniels scott.dani...@acm.org: mark.sea...@gmail.com wrote: On Mar 29, 9:52 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 29, 2009 at 9:18 PM,  mark.sea...@gmail.com wrote: ... ... Also, you

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

2009-03-30 Thread Hrvoje Niksic
mark.sea...@gmail.com writes: 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

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

2009-03-30 Thread Jan Decaluwe
mark.sea...@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

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

2009-03-30 Thread mark . seagoe
On Mar 30, 2:30 am, Jan Decaluwe j...@jandecaluwe.com wrote: mark.sea...@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

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

2009-03-30 Thread mark . seagoe
It needs to read HW reg and adjust ChipRegister value, or ShadowRegister and change the HW value (order was reversed). I will look at MyHDL again though to see if there is some reason it can print class subclassed from intbv, or if it even has a class subclassed from intbv, without casting as a

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

2009-03-30 Thread mark . seagoe
Here again is example: from ctypes import * class REG_INFO(Structure): _fields_ = [ ('address', c_ubyte), ('message', c_char * 256), ('size', c_ubyte) ] class myclass(object): # # def __new__(class_, init_val, size, reg_info): def __init__(self,

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

2009-03-30 Thread MRAB
mark.sea...@gmail.com wrote: Here again is example: from ctypes import * class REG_INFO(Structure): _fields_ = [ ('address', c_ubyte), ('message', c_char * 256), ('size', c_ubyte) ] class myclass(object): # # def __new__(class_, init_val, size,

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

2009-03-30 Thread Scott David Daniels
mark.sea...@gmail.com wrote: ... It seems like there's no way to do what I'm trying. I am confined to 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

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

2009-03-30 Thread David Bolen
mark.sea...@gmail.com writes: class myclass(object): # # def __new__(class_, init_val, size, reg_info): def __init__(self, init_val, size, reg_info): # self = object.__new__(class_) self.reg_info = reg_info print self.reg_info.message self.val =

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

2009-03-30 Thread mark . seagoe
On Mar 30, 9:40 am, Scott David Daniels scott.dani...@acm.org wrote: mark.sea...@gmail.com wrote: ... It seems like there's no way to do what I'm trying.  I am confined to Python 2.5.3 for business reasons. So I want a class ShadowRegister, which just has a value that I can do get/set

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

2009-03-30 Thread mark . seagoe
On Mar 30, 10:53 am, David Bolen db3l@gmail.com wrote: mark.sea...@gmail.com writes: class myclass(object): #     # def __new__(class_, init_val, size, reg_info):     def __init__(self, init_val, size, reg_info):         # self = object.__new__(class_)         self.reg_info =

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

2009-03-30 Thread mark . seagoe
If I cast it long then it prints fine, but I was hoping there would be a slicker way (to accomplish this in the class itself). print 'bird val = 0x%016X' % long(bird) -- http://mail.python.org/mailman/listinfo/python-list

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

2009-03-30 Thread Dave Angel
After taking out the class myclass stuff, the code worked for me in Python 2.6.1, through the cat line. Could you please tell us what version of Python you're running this on? import sys print Python version: , sys.version yielded (on my machine) Python version: 2.6.1 (r261:67517, Dec 4

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

2009-03-30 Thread mark . seagoe
On Mar 30, 11:53 am, Dave Angel da...@ieee.org wrote: After taking out the class  myclass stuff, the code worked for me in Python 2.6.1, through the cat line.  Could you please tell us what version of Python you're running this on? import sys print Python version: , sys.version yielded (on

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

2009-03-30 Thread mark . seagoe
On Mar 30, 12:01 pm, mark.sea...@gmail.com wrote: On Mar 30, 11:53 am, Dave Angel da...@ieee.org wrote: After taking out the class  myclass stuff, the code worked for me in Python 2.6.1, through the cat line.  Could you please tell us what version of Python you're running this on?

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

2009-03-30 Thread mark . seagoe
On Mar 30, 12:05 pm, mark.sea...@gmail.com wrote: On Mar 30, 12:01 pm, mark.sea...@gmail.com wrote: On Mar 30, 11:53 am, Dave Angel da...@ieee.org wrote: After taking out the class  myclass stuff, the code worked for me in Python 2.6.1, through the cat line.  Could you please tell

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

2009-03-30 Thread Dave Angel
Sorry, I meant I took out the stuff *before* the definition of class myclass, and also those things that referred to it. I didn't want to import ctypes, because it couldn't have any effect on the problem at hand. Since then I see that you've succeeded with the __int__() method call, and

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

2009-03-30 Thread Rhodri James
On Mon, 30 Mar 2009 18:57:01 +0100, mark.sea...@gmail.com wrote: Thanks Scott. I think you are saying don't try to subclass from type long, because it is immutable (cannot be changed). If I subclass from type object, then the value can be changed, but I still can't print without explicitely

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

2009-03-30 Thread mark . seagoe
Just as feedback, I went back to the __init__ style routine, weeded out a few things, installed python 2.6.1, and it works great. Thanks for all your help. Now I've got to convince 1000 people at my company to switch. That's going to be the tough part. --

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

2009-03-29 Thread mark . seagoe
Hi. So now I have this class that works to allow me to pass in my reg_info struct. However when I try to make it part of my class it gets an error global name 'self' is not defined. I've never seen this error before. If I comment out the line below 'self.reg_info = reg_info then the code

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

2009-03-29 Thread Chris Rebert
On Sun, Mar 29, 2009 at 9:18 PM, mark.sea...@gmail.com wrote: Hi.  So now I have this class that works to allow me to pass in my reg_info struct.  However when I try to make it part of my class it gets an error global name 'self' is not defined.  I've never seen this error before.  If I

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

2009-03-29 Thread mark . seagoe
On Mar 29, 9:52 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 29, 2009 at 9:18 PM,  mark.sea...@gmail.com wrote: Hi.  So now I have this class that works to allow me to pass in my reg_info struct.  However when I try to make it part of my class it gets an error global name 'self' is