Re: ClassName.attribute vs self.__class__.attribute

2008-06-13 Thread Gabriel Rossetti
Duncan Booth wrote: Mike Orr [EMAIL PROTECTED] wrote: That's a misunderstanding of classes vs instances. If you have an instance of MyClass(Superclass), there is one instance but several classes. The instance is of MyClass; there is no instance of Superclass. 'self' has a .__class__

Re: ClassName.attribute vs self.__class__.attribute

2008-06-13 Thread Bruno Desthuilliers
Duncan Booth a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote: FWIW, metaclasses do have a class attribute that refers to itself !-) One metaclass (i.e. type) has a class attribute that refers to itself. Other metaclasses have a class attribute that refers to the metaclass's

Re: ClassName.attribute vs self.__class__.attribute

2008-06-13 Thread Terry Reedy
One metaclass (i.e. type) has a class attribute that refers to itself. Other metaclasses have a class attribute that refers to the metaclass's metaclass. I can't think of any situation where a metaclass would be its own metaclass except for 'type' itself, but then I think I've got a

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Gabriel Rossetti
Mike Orr wrote: On Jun 5, 8:40 am, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Duncan Booth
Mike Orr [EMAIL PROTECTED] wrote: That's a misunderstanding of classes vs instances. If you have an instance of MyClass(Superclass), there is one instance but several classes. The instance is of MyClass; there is no instance of Superclass. 'self' has a .__class__ attribute because it's an

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Hrvoje Niksic
Mike Orr [EMAIL PROTECTED] writes: There's a very good reason to use self.__class__: it makes it possible to subclass your class. This really depends on the usage. In the OP's use case, he wanted the subclasses to share the same lock object defined in the superclass (because of

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Bruno Desthuilliers
Mike Orr a écrit : (snip) 'self' has a .__class__ attribute because it's an instance, but MyClass and Superclass do not because they're already classes. Not true for new-style classes: class Toto(object): pass ... Toto.__class__ type 'type' (snip) I sometimes wish classes had a

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Duncan Booth
Bruno Desthuilliers [EMAIL PROTECTED] wrote: FWIW, metaclasses do have a class attribute that refers to itself !-) One metaclass (i.e. type) has a class attribute that refers to itself. Other metaclasses have a class attribute that refers to the metaclass's metaclass. I can't think of any

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Hrvoje Niksic
Duncan Booth [EMAIL PROTECTED] writes: In fact, thinking about it a bit more, I think that if you did have another metaclass which is its own metaclass then the class cannot subclass 'object'. You could if the metaclass of your metaclass inherited from 'type'. Then your types could still be

Re: ClassName.attribute vs self.__class__.attribute

2008-06-11 Thread Mike Orr
On Jun 5, 8:40 am, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a class using

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Gabriel Rossetti
Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a class using this technique and

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On 5 juin, 17:40, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. It's

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Bruno Desthuilliers
Gabriel Rossetti a écrit : Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread David C. Ullrich
In article [EMAIL PROTECTED], Gabriel Rossetti [EMAIL PROTECTED] wrote: Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Casey McGinty
On Thu, Jun 5, 2008 at 11:39 AM, Terry Reedy [EMAIL PROTECTED] wrote: If you want to access the attribute of a particular class, to read or write, use that class. SomeClass.attr Note that no instance is required or relevant. If you want to read the attrubute of the class of an instance

Re: ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Larry Bates
Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a class using this technique and from there on things

Re: ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread [EMAIL PROTECTED]
On 5 juin, 17:40, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. It's even prefered to use self.attribute, unless you know you have both an

Re: ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Casey McGinty
On Thu, Jun 5, 2008 at 5:40 AM, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a

Re: ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Terry Reedy
Casey McGinty [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On Thu, Jun 5, 2008 at 5:40 AM, Gabriel Rossetti | [EMAIL PROTECTED] wrote: | | Hello everyone, | | I had read somewhere that it is preferred to use self.__class__.attribute | over ClassName.attribute to access class

Re: ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Hrvoje Niksic
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: On 5 juin, 17:40, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. It's even prefered to use