Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-15 Thread Jim Jewett
On 3/9/07, Talin <[EMAIL PROTECTED]> wrote: > Note that the Python interpreter will check to insure that the > __metacreate__ attribute exists before calling it. This preserves > backwards compatibility with existing metaclasses. You might want to be even more explicit and say If t

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-14 Thread Guido van Rossum
On 3/14/07, Jack Diederich <[EMAIL PROTECTED]> wrote: > I've snipped all the bits I understand and/or agree with. I'm only quoting what I think needs clarification and/or hasn't already been addressed. Note you're responding to an old thread; Talin posted a new version of the PEP and I checked it

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-14 Thread Josiah Carlson
Jack Diederich <[EMAIL PROTECTED]> wrote: [snip] > I don't understand the keyword args other than 'metaclass.' > If class D inherits from class C does it also get passed the 'Implements' > keyword? If it does the same effect could be acheived by making a metaclass > maker function and just using

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-14 Thread Jack Diederich
On Mon, Mar 12, 2007 at 05:30:48PM -0700, Guido van Rossum wrote: > Executive summary: I'm defending the PEP and the metaclass syntax it > proposes, and in fact I want the "clas arguments" to have the same > syntax as a call, including *args and **kwds. I'm only suggesting to > find a new name inst

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-14 Thread Guido van Rossum
On 3/13/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > For uniformity and generality I propose to keep it. So the absolute > > minimal signature for __prepare__ is actually: > > > > def __prepare__(name, bases, *, metaclass=None): ... > > > > this way the prepare functio

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Talin
Ack, I meant to hit cancel and not Send. Please ignore that. Talin wrote: > Guido van Rossum wrote: >>> I'm a bit worried that class headers are going to become >>> rather cluttered if we start putting all sorts of stuff >>> in there. >>> >>> E.g. are you intending to put __slots__ there? It makes

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Talin
Guido van Rossum wrote: >> I'm a bit worried that class headers are going to become >> rather cluttered if we start putting all sorts of stuff >> in there. >> >> E.g. are you intending to put __slots__ there? It makes >> sense, but it could lead to some rather long and >> unwieldy class headers. >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Greg Ewing
Guido van Rossum wrote: > For uniformity and generality I propose to keep it. So the absolute > minimal signature for __prepare__ is actually: > > def __prepare__(name, bases, *, metaclass=None): ... > > this way the prepare function can > distinguish between an explicit and an implied metaclass

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Josiah Carlson
"Thomas Wouters" <[EMAIL PROTECTED]> wrote: > On 3/13/07, BJorn Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 3/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > > > I find this rather cool looking: > > > > > > > > > > class C(implements=(I1, I2)): ... > > > > > > Me too. :-) > > > Wh

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Thomas Wouters
On 3/13/07, BJörn Lindqvist <[EMAIL PROTECTED]> wrote: On 3/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > I find this rather cool looking: > > > > > > class C(implements=(I1, I2)): ... > > Me too. :-) Who is the receiver of the implements keyword argument in your example? Should

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Guido van Rossum
I think we've definitely entered the bikeshed color discussion now. I'm holding out for Talin's revised version of the PEP. On 3/13/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > But in slightly longer examples, I think that the looks are > > significantly improved... > >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Nick Coghlan
Josiah Carlson wrote: > But in slightly longer examples, I think that the looks are > significantly improved... > > class Foo(base1, base2, *otherbases, metaclass=mymeta, > private=True, **kwargs): > ... > > vs. > > @@(metaclass=mymeta, private=True, **kwargs) > class

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Phillip J. Eby
At 02:26 PM 3/13/2007 -0700, Josiah Carlson wrote: >But in slightly longer examples, I think that the looks are >significantly improved... > > class Foo(base1, base2, *otherbases, metaclass=mymeta, > private=True, **kwargs): > ... > >vs. > > @@(metaclass=mymeta, private=True

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > On 3/13/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > > I'm a bit worried that class headers are going to become > > rather cluttered if we start putting all sorts of stuff > > in there. > > > > E.g. are you intending to put __slots__ there? It makes >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Georg Brandl
BJörn Lindqvist schrieb: > On 3/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> > > I find this rather cool looking: >> > > >> > > class C(implements=(I1, I2)): ... >> >> Me too. :-) > > But... What does it do? PEP says: > > In the new model, the syntax for specifying a metaclass is via a

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread BJörn Lindqvist
On 3/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > I find this rather cool looking: > > > > > > class C(implements=(I1, I2)): ... > > Me too. :-) But... What does it do? PEP says: In the new model, the syntax for specifying a metaclass is via a keyword argument in the list of base cl

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Thomas Wouters
On 3/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: [Quoting Greg E. quoting Guido] > > I find this rather cool looking: > > > > class C(implements=(I1, I2)): ... Me too. :-) Boy, you really like it, don't you. Me, too, though. Will that be the syntax for ABCs then, rather than that si

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Guido van Rossum
Another bulk reply... On 3/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > Maybe I'm misunderstanding but isn't this a reason that you'd *want* > the ``**kwargs`` signature? With the plain ``kwargs`` signature from > the PEP you'd have to do something like:: > > def __prepare__(name, args,

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Phillip J. Eby
At 10:33 PM 3/13/2007 +1000, Nick Coghlan wrote: >Greg Ewing wrote: > > If they're passed to both, then the signatures become > > > >metaclass.__prepare__(name, bases, **kwargs) > >metaclass(name, bases, body, **kwargs) > > > > BTW, I don't think I like the name "__prepare__" much > > more

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Phillip J. Eby
At 09:45 PM 3/12/2007 -0600, Steven Bethard wrote: >On 3/12/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > At 09:32 PM 3/12/2007 -0600, Steven Bethard wrote: > > >On 3/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > > > > the signature of the method called will be:: > > > > __prepare__(na

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Nick Coghlan
Greg Ewing wrote: > Nick Coghlan wrote: >> Along similar lines, I'd be marginally happier with: >> >>class Bob(meta=Planet): pass > > Is there some way we could remove the word "meta" > from the syntax altogether? I don't mind using > it in conversation, but it seems a tad too geeky > to have

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Nick Coghlan
Greg Ewing wrote: > If they're passed to both, then the signatures become > >metaclass.__prepare__(name, bases, **kwargs) >metaclass(name, bases, body, **kwargs) > > BTW, I don't think I like the name "__prepare__" much > more than "__metacreate__". It seems just as wooly. > What's being

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Greg Ewing
Nick Coghlan wrote: > Along similar lines, I'd be marginally happier with: > >class Bob(meta=Planet): pass Is there some way we could remove the word "meta" from the syntax altogether? I don't mind using it in conversation, but it seems a tad too geeky to have as an actual part of the languag

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Greg Ewing
Nick Coghlan wrote: > - is it intended to typically be a static method or a class method of > the metaclass? (as it will be called before __new__, an instance method > of the metaclass wouldn't make sense) Looks like it will have to be either a staticmethod or classmethod, or else you'll have

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Greg Ewing
Guido van Rossum wrote: > > On 3/10/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > > > class Foo: > > class __metaclass__: > > Personally, I find code that does this completely unreadable The reason I'd be a little disappointed to lose this is that it provides a concise way of defining genuin

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Greg Ewing
Steven Bethard wrote: > Initially, I was concerned that this would break the symmetry with the > __metaclass__ signature:: > > def __metaclass__(name, bases, bodydict): > def __prepare__(name, bases, kwargs): Can someone clarify something here: Are the keywords going to be passed to the p

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-13 Thread Nick Coghlan
Guido van Rossum wrote: > On 3/9/07, Steven Bethard <[EMAIL PROTECTED]> wrote: >> >> I'd rather __metacreate__ be called something like __createdict__, >> __creationdict__, __metadict__, __getmetadict__, etc. where it's >> clearer that the purpose is to create a dict object. >> > > Agreed; there

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Steven Bethard
On 3/12/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 09:32 PM 3/12/2007 -0600, Steven Bethard wrote: > >On 3/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > > > the signature of the method called will be:: > > > __prepare__(name, args, kwargs) > > > not > > > __prepare__(name, *arg

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Phillip J. Eby
At 09:32 PM 3/12/2007 -0600, Steven Bethard wrote: >On 3/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > > the signature of the method called will be:: > > __prepare__(name, args, kwargs) > > not > > __prepare__(name, *args, **kwargs) > > right? > >On 3/12/07, Guido van Rossum <[EMAIL PR

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Steven Bethard
On 3/12/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > the signature of the method called will be:: > __prepare__(name, args, kwargs) > not > __prepare__(name, *args, **kwargs) > right? On 3/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I'm not sure anyone has thought much about it

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Guido van Rossum
Unsure why you present this as a question; I'm not sure anyone has thought much about it yet. I wonder if the call shouldn't be made like this: __prepare__(name, bases, **kwargs) so that if you only expect certain specific keyword args you can define it like this: def __prepare__(name, base, met

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] FWIW, I agree that class definition meta-information should go in the header rather that the body. To me, metaclass=mymeta at the top is much prettier than __metaclass__ = mymeta in the body. It will also make it

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Steven Bethard
On 3/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 3/9/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > > Do the keywords have to follow the metaclass keyword, or is order > > irrelevant? While order makes sense, it would be a new precedent for > > keyword arguments to have an important ord

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Guido van Rossum
On 3/12/07, Collin Winter <[EMAIL PROTECTED]> wrote: > On 3/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [snip stuff I agree with] > > On 3/9/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > > > Do the keywords have to follow the metaclass keyword, or is order > > > irrelevant? While order ma

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Phillip J. Eby
At 05:30 PM 3/12/2007 -0700, Guido van Rossum wrote: >I don't know about sealed, but using class attributes topassing >parameter (other than the namespace itself) to the metaclass seems a >pretty lousy mechanism, and keyword arguments in the classdef are a >much cleaner solution for this need. For

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Collin Winter
On 3/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: [snip stuff I agree with] > On 3/9/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > > Do the keywords have to follow the metaclass keyword, or is order > > irrelevant? While order makes sense, it would be a new precedent for > > keyword argument

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-12 Thread Guido van Rossum
On 3/9/07, Talin <[EMAIL PROTECTED]> wrote: > I had a conversation with Guido last night at the Python user's group > meeting, and we hashed out some of the details of how metaclasses should > work. I've gone ahead and written up a PEP, which I present for your review. Executive summary: I'm defen

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-11 Thread Georg Brandl
Greg Ewing schrieb: > Some more metaclass syntax ideas: > >class Foo[Meta](bases): > ... > >Meta class Foo(bases): > ... > > although I don't like the way the latter moves the > 'class' keyword away from the beginning. You could even unify metaclass and class decorator, if you

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Talin wrote: > The main reason for doing it the way that I did, is to allow for > the future possibility of the *default* metaclass interpreting some of > those keywords. Hmmm. I can see how you would need some way of passing keywords in order to do that. But in the absence of any real use cases

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Josiah Carlson wrote: > class foo(...): > a = ... > __metaclass__ = callable(a, ...) Personally I wouldn't mind if it were made a requirement that __metaclass__, if it is present, must be the first name bound in the class body (and can't be inside an if statement, etc.) Does

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > I did have a post that was going to show that they were related, but > > then I remembered that because of __metaclass__ assignment semantics, it > > needs to necessarily have access to the class body dictionary at the > > point of

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Josiah Carlson wrote: > I did have a post that was going to show that they were related, but > then I remembered that because of __metaclass__ assignment semantics, it > needs to necessarily have access to the class body dictionary at the > point of assignment, so the compiler, etc., cannot be tau

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Josiah Carlson wrote: > As such, the compiler, etc., needs to be taught to pull out the > __metaclass__ definition before executing the class body, but that's > better than mucking with the syntax of class foo(...). I'd be happy with that. Also, for the name of the method for creating the dict,

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Talin
Talin wrote: > I'll give you an example: Suppose the author of Pyrex realizes that Of course, only an idiot would be unaware that "the author of Pyrex" is in fact the person who he is replying to. Which means I must have meant to do that. Uh-huh. Right. :) -- Talin

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Talin
Greg Ewing wrote: > Another thought: It's not strictly necessary to > allow for arguments to the metaclass, since the same > effect can be achieved with a factory function, like > we do for decorators. True. The main reason for doing it the way that I did, is to allow for the future possibility o

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Some more metaclass syntax ideas: class Foo[Meta](bases): ... Meta class Foo(bases): ... although I don't like the way the latter moves the 'class' keyword away from the beginning. Another thought: It's not strictly necessary to allow for arguments to the metaclass, since the sa

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Greg Ewing
Talin wrote: > The relation > between a class and a metaclass isn't well-expressed with 'as', 'is', or > 'equals'. Okay, then make it class Foo(base1, base2) isa MyMeta: ... -- Greg ___ Python-3000 mailing list Python-3000@python.org http://

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Josiah Carlson
"Phillip J. Eby" <[EMAIL PROTECTED]> wrote: > At 12:40 PM 3/10/2007 -0800, Josiah Carlson wrote: > > >Talin <[EMAIL PROTECTED]> wrote: > > > I strongly feel that this makes *using* metaclasses way too complex. A > > > person wanting to create a C struct or a database record should simply > > > ha

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Phillip J. Eby
At 12:40 PM 3/10/2007 -0800, Josiah Carlson wrote: >Talin <[EMAIL PROTECTED]> wrote: > > I strongly feel that this makes *using* metaclasses way too complex. A > > person wanting to create a C struct or a database record should simply > > have to say "metaclass=cstruct" - they shouldn't have to de

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Josiah Carlson
Talin <[EMAIL PROTECTED]> wrote: > I strongly feel that this makes *using* metaclasses way too complex. A > person wanting to create a C struct or a database record should simply > have to say "metaclass=cstruct" - they shouldn't have to declare a bunch > of individual pieces, all of which have

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Phillip J. Eby
At 08:45 PM 3/10/2007 +1300, Greg Ewing wrote: >Jack Diederich wrote: > > > I am a very big fan of ordered dicts in classes. One possibility is that > > suites in classes always store their order in a special dict that keeps a > > side list of key order. A final invisible class decorator around >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Talin
Josiah Carlson wrote: > There are two semantics that I would be happy with. Either force > metaclasses to have a .metadict() or equivalent method (or a callable > attribute in the case of arbitrary callables), or even allow > __metaclass__ to be a tuple: > > class foo(...): > __metacl

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > > Talin wrote: > > >class Foo(base1, base2, metaclass=mymeta): > > ... > > -1 on this syntax, I think it's ugly. > > Alternative proposals: > >class Foo(base1, base2) as MyMeta: > ... While I don't particularly like the foo(b

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Georg Brandl
Jack Diederich schrieb: > I am a very big fan of ordered dicts in classes. One possibility is that > suites in classes always store their order in a special dict that keeps a > side list of key order. A final invisible class decorator around > every class would then toss out the order and leave

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Talin
Greg Ewing wrote: > Talin wrote: > >>class Foo(base1, base2, metaclass=mymeta): >> ... > > -1 on this syntax, I think it's ugly. All I can say is, beauty is in the eye, etc...in any case, I'm not the one to decide what's pretty and what's not. > Alternative proposals: > >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Talin
Josiah Carlson wrote: > Also, depending on the use, one may want to know the order in a 'move to > end' fashion (if a is assigned to multiple times, it ends up in the > ordering as if only the last assignment was done). This is why I feel it is insufficient to keep just a record of what key names

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-10 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > > Jack Diederich wrote: > > > I am a very big fan of ordered dicts in classes. One possibility is that > > suites in classes always store their order in a special dict that keeps a > > side list of key order. A final invisible class decorator around > >

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Greg Ewing
Jack Diederich wrote: > I am a very big fan of ordered dicts in classes. One possibility is that > suites in classes always store their order in a special dict that keeps a > side list of key order. A final invisible class decorator around > every class would then toss out the order and leave o

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Greg Ewing
Talin wrote: >class Foo(base1, base2, metaclass=mymeta): > ... -1 on this syntax, I think it's ugly. Alternative proposals: class Foo(base1, base2) as MyMeta: ... or class Foo(base1, base2) = MyMeta: ... >class Foo(base1, base2, metaclass=mymeta, priv

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Jack Diederich
On Fri, Mar 09, 2007 at 12:44:36PM -0800, Talin wrote: > I had a conversation with Guido last night at the Python user's group > meeting, and we hashed out some of the details of how metaclasses should > work. I've gone ahead and written up a PEP, which I present for your review. > --

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Brett Cannon
On 3/9/07, Talin <[EMAIL PROTECTED]> wrote: > I had a conversation with Guido last night at the Python user's group > meeting, and we hashed out some of the details of how metaclasses should > work. I've gone ahead and written up a PEP, which I present for your review. > ---

Re: [Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Steven Bethard
On 3/9/07, Talin <[EMAIL PROTECTED]> wrote: > PEP: xxx > Title: Metaclasses in Python 3000 Thanks for writing this. > This attribute is a method named __metacreate__, which is invoked > before the evaluation of the class body, and which has the > following form: > > classdict

[Python-3000] PEP for Metaclasses in Python 3000

2007-03-09 Thread Talin
I had a conversation with Guido last night at the Python user's group meeting, and we hashed out some of the details of how metaclasses should work. I've gone ahead and written up a PEP, which I present for your review. PEP: xxx Title: Metaclasses in P