Re: Re[2]: Re: class proposal
Lenard Lindstrom <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <Mahogany-0.66.0-4294595635-20040702-163218.00@pop3.norton.antivirus> |
On Wed, 30 Jun 2004 14:58:14 -0700 Mark Hahn <[email protected]> wrote: > Serge Orlov wrote: > > >> Serge gave me a reference to some metaclass examples. I am in the > >> process of trying to understand them and see how Prothon would deal > >> with them. Serge himself says that metaclasses are only decorators, > >> whatever that means. > > > > I don't remember saying *are only* decorators, I think I wrote > > "mostly as". I also think it's abuse. > > > > What do you mean whatever that [decorators] means? > > I just meant that I don't understand how metaclasses act as decorators. > That is no surprise since I don't understand what metaclasses really are. > This is my problem. > Since all objects in an object oriented language have a class, and in Python classes are objects, then class objects need a class as well. The default class of new-style objects is class "type". Since type is the class of a class it is called a metaclass. Just as a class has as attributes the methods used by its instances, "type" has the methods of its instances, classes (not to be confused with class methods). An example, type's __call__ method is used to create classes. What confuses people with Python is one can choose to create classes that are instances of something other than object "type". So metaclasses are visible in Python. Lenard Lindstrom <[email protected]>