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__
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
[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
21 matches
Mail list logo