Re: Trying to learn about metaclasses

2011-07-30 Thread Steven D'Aprano
bruno.desthuilli...@gmail.com wrote: > On 25 juil, 17:36, "Steven W. Orr" wrote: >> I have been doing a lot of reading. I'm starting to get it. I think it's >> really cool as well as dangerous, > > Dangerous ??? Why so ? Is there anything "dangerous" in a constructor > or an initialiser ??? A me

Re: Trying to learn about metaclasses

2011-07-30 Thread bruno.desthuilli...@gmail.com
On 25 juil, 17:36, "Steven W. Orr" wrote: > I have been doing a lot of reading. I'm starting to get it. I think it's > really cool as well as dangerous, Dangerous ??? Why so ? Is there anything "dangerous" in a constructor or an initialiser ??? A metaclass is just a class, and a class is just an

Re: Trying to learn about metaclasses

2011-07-26 Thread Thomas Jollans
On 26/07/11 04:44, Victor Khangulov wrote: > Hi Steven, > > I too am just learning about metaclasses in Python and I found the > example you posted to be excellent. > > I played around with it and noticed that the issue seems to be the > double-underscore in front of the fields (cls.__fields = {}

Re: Trying to learn about metaclasses

2011-07-25 Thread Victor Khangulov
Hi Steven, I too am just learning about metaclasses in Python and I found the example you posted to be excellent. I played around with it and noticed that the issue seems to be the double-underscore in front of the fields (cls.__fields = {}). If you change this parameter to use the single-u

Re: Trying to learn about metaclasses

2011-07-25 Thread Chris Kaynor
On Mon, Jul 25, 2011 at 8:36 AM, Steven W. Orr wrote: > I have been doing a lot of reading. I'm starting to get it. I think it's > really cool as well as dangerous, but I plan on being respectful of the > construct. I found a web page that I found quite readable. > > http://cleverdevil.org/**comp

Re: Trying to learn about metaclasses

2011-07-25 Thread Karim
Very good. Karim On 07/25/2011 05:46 PM, jfine wrote: Hi I gave a tutorial at this year's EuroPython that covered metaclasses. You can get the tutorial materials from a link on: http://ep2011.europython.eu/conference/talks/objects-and-classes-in-python-and-javascript Jonathan -- http://ma

Re: Trying to learn about metaclasses

2011-07-25 Thread Peter Otten
Steven W. Orr wrote: > I have been doing a lot of reading. I'm starting to get it. I think it's > really cool as well as dangerous, but I plan on being respectful of the > construct. I found a web page that I found quite readable. > > http://cleverdevil.org/computing/78/ > > So, I tried to run t

Re: Trying to learn about metaclasses

2011-07-25 Thread jfine
Hi I gave a tutorial at this year's EuroPython that covered metaclasses. You can get the tutorial materials from a link on: http://ep2011.europython.eu/conference/talks/objects-and-classes-in-python-and-javascript Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Trying to learn about metaclasses

2011-07-25 Thread Steven W. Orr
I have been doing a lot of reading. I'm starting to get it. I think it's really cool as well as dangerous, but I plan on being respectful of the construct. I found a web page that I found quite readable. http://cleverdevil.org/computing/78/ So, I tried to run the example code (below), and I ge

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. -- http://mail.python.org/mailman/listinfo

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, 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 casting back to long in

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 your

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 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 u

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 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 sy

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 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 my m

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
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: global name 'self' is not defined - noob trying to learn

2009-03-30 Thread mark . seagoe
On Mar 30, 10:53 am, David Bolen 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 = reg_info

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 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 bit sel an

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.

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 from

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, reg_info

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, init_

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 l

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 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 "object".  Then

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 ShadowRe

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 har

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 wrote: > 2009/3/29 Scott David Daniels : > > > mark.sea...@gmail.com wrote: > > >> On Mar 29, 9:52 pm, Chris Rebert wrote: > > >>> On Sun, Mar 29, 2009 at 9:18 PM,   wrote: > > ... > > >>> ... Also, you shouldn't use `class_ ` as the name of the first argume

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

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

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

2009-03-29 Thread Scott David Daniels
mark.sea...@gmail.com wrote: On Mar 29, 9:52 pm, Chris Rebert wrote: On Sun, Mar 29, 2009 at 9:18 PM, 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 for it. Actually, according to PEP 8,

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 wrote: > On Sun, Mar 29, 2009 at 9:18 PM,   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

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, 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 comment out the line b

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 runs

Re: Trying to learn

2008-07-11 Thread Gabriel Genellina
En Fri, 11 Jul 2008 05:49:23 -0300, Ben Finney <[EMAIL PROTECTED]> escribi�: luster123 <[EMAIL PROTECTED]> writes: Can someone please teach me the basics of Python and Pygame? Yes, you can do it. http://docs.python.org/tut/tut.html> http://www.python.org/doc/> http://clusty.com/search?que

Re: Trying to learn

2008-07-11 Thread Ben Finney
luster123 <[EMAIL PROTECTED]> writes: > Can someone please teach me the basics of Python and Pygame? Yes, you can do it. http://docs.python.org/tut/tut.html> http://www.python.org/doc/> http://clusty.com/search?query=pygame+tutorial> -- \ “Too many pieces of music finish too long after th

Trying to learn

2008-07-11 Thread luster123
Hey, Can someone please teach me the basics of Python and Pygame? -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to Learn Packages

2008-06-22 Thread Saul Spatz
Cédric Lucantis wrote: Le Sunday 22 June 2008 16:07:37 Saul Spatz, vous avez écrit : Hi, I'm making a project into my first package, mainly for organization, but also to learn how to do it. I have a number of data files, both experimental results and PNG files. My project is organized as a ro

Re: Trying to Learn Packages

2008-06-22 Thread Cédric Lucantis
Le Sunday 22 June 2008 16:07:37 Saul Spatz, vous avez écrit : > Hi, > > I'm making a project into my first package, mainly for organization, but > also to learn how to do it. I have a number of data files, both > experimental results and PNG files. My project is organized as a root > directory, w

Re: Trying to Learn Packages

2008-06-22 Thread David
On Sun, Jun 22, 2008 at 4:07 PM, Saul Spatz <[EMAIL PROTECTED]> wrote: > Hi, > > I'm making a project into my first package, mainly for organization, but > also to learn how to do it. I have a number of data files, both > experimental results and PNG files. My project is organized as a root > dir

Trying to Learn Packages

2008-06-22 Thread Saul Spatz
Hi, I'm making a project into my first package, mainly for organization, but also to learn how to do it. I have a number of data files, both experimental results and PNG files. My project is organized as a root directory, with two subdirectories, src and data, and directory trees below them.