Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-06 Thread PJ Eby
On Wed, Jun 6, 2012 at 5:31 AM, Nick Coghlan wrote: > On Wed, Jun 6, 2012 at 5:09 PM, Nick Coghlan wrote: > > On Wed, Jun 6, 2012 at 1:28 AM, PJ Eby wrote: > >> To be clear, what I specifically proposed (as I mentioned in an earlier > >> thread) was simply to patch __build_class__ in order to r

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-06 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 5:09 PM, Nick Coghlan wrote: > On Wed, Jun 6, 2012 at 1:28 AM, PJ Eby wrote: >> To be clear, what I specifically proposed (as I mentioned in an earlier >> thread) was simply to patch __build_class__ in order to restore the missing >> __metaclass__ hook.  (Which, incidentall

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-06 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 1:28 AM, PJ Eby wrote: > To be clear, what I specifically proposed (as I mentioned in an earlier > thread) was simply to patch __build_class__ in order to restore the missing > __metaclass__ hook.  (Which, incidentally, would make ALL code using > __metaclass__ cross-version

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 1:48 PM, PJ Eby wrote: > On Tue, Jun 5, 2012 at 8:14 PM, Nick Coghlan wrote: >> >> On reflection, I'm actually inclined to agree. The next version of the >> PEP will propose the addition of type.__decorate__(). This new method >> will be invoked *after* the class is created

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread PJ Eby
On Tue, Jun 5, 2012 at 8:14 PM, Nick Coghlan wrote: > On reflection, I'm actually inclined to agree. The next version of the > PEP will propose the addition of type.__decorate__(). This new method > will be invoked *after* the class is created and the __class__ cell is > populated, but *before* l

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 2:00 AM, Joao S. O. Bueno wrote: > On 5 June 2012 09:24, Nick Coghlan wrote: > >> >> PEP written and posted: http://www.python.org/dev/peps/pep-0422/ >> More toy examples here: >> https://bitbucket.org/ncoghlan/misc/src/default/pep422.py >> >> Yes, it means requiring the us

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 1:28 AM, PJ Eby wrote: > IOW, my motivation for saying, "hey, can't I just use this nice hook here" > was to avoid asking for a *new* feature, if there weren't enough other > people interested in a decoration protocol of this sort. > > That is, I was trying to NOT make anybo

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Joao S. O. Bueno
On 5 June 2012 09:24, Nick Coghlan wrote: > > PEP written and posted: http://www.python.org/dev/peps/pep-0422/ > More toy examples here: > https://bitbucket.org/ncoghlan/misc/src/default/pep422.py > > Yes, it means requiring the use of a specific metaclass in 3.2 (either > directly or via inherit

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread PJ Eby
On Tue, Jun 5, 2012 at 3:53 AM, Nick Coghlan wrote: > Please don't try to coerce everyone else into supporting such an ugly > hack by abusing an implementation detail. Whoa, whoa there. Again with the FUD. Sorry if I gave the impression that I'm about to unleash the monkeypatching hordes tomo

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 10:37 PM, Xavier Morel wrote: > On 5 juin 2012, at 14:24, Nick Coghlan wrote: >>> Metaclasses *do* have a problem with composition and lexical >>> decorators don't play nicely with inheritance, but a dynamic decorator >>> system modelled to some degree on the old __metaclas

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Xavier Morel
On 5 juin 2012, at 14:24, Nick Coghlan wrote: > On Tue, Jun 5, 2012 at 8:25 PM, Nick Coghlan wrote: >> On Tue, Jun 5, 2012 at 7:11 PM, Michael Foord >> wrote: >>> >>> On 5 Jun 2012, at 08:53, Nick Coghlan wrote: >>> [snip...] Now, one minor annoyance with current class decora

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 8:25 PM, Nick Coghlan wrote: > On Tue, Jun 5, 2012 at 7:11 PM, Michael Foord > wrote: >> >> On 5 Jun 2012, at 08:53, Nick Coghlan wrote: >> >>> [snip...] >>> >>> Now, one minor annoyance with current class decorators is that they're >>> *not* inherited. This is sometimes w

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Joao S. O. Bueno
On 4 June 2012 21:10, PJ Eby wrote: >> > I only use __metaclass__ in 2.x for this because it's the only way for >> > code >> > executed in a class body to gain access to the class at creation time. >> > PJ, it maybe just me, but what does this code do that can't be done at the metaclass' __new__

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 7:11 PM, Michael Foord wrote: > > On 5 Jun 2012, at 08:53, Nick Coghlan wrote: > >> [snip...] >> >> Now, one minor annoyance with current class decorators is that they're >> *not* inherited. This is sometimes what you want, but sometimes you >> would prefer to automatically

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Michael Foord
On 5 Jun 2012, at 08:53, Nick Coghlan wrote: > [snip...] > > Now, one minor annoyance with current class decorators is that they're > *not* inherited. This is sometimes what you want, but sometimes you > would prefer to automatically decorate all subclasses as well. > Currently, that means writi

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-05 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 2:03 PM, PJ Eby wrote: > On Mon, Jun 4, 2012 at 10:43 PM, Eric Snow > wrote: >> >> On Mon, Jun 4, 2012 at 6:10 PM, PJ Eby wrote: >> > I mean that class-level __metaclass__ is no longer supported as of PEP >> > 3115, >> > so I can't use that as a way to non-invasively obtai

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread PJ Eby
On Mon, Jun 4, 2012 at 10:43 PM, Eric Snow wrote: > On Mon, Jun 4, 2012 at 6:10 PM, PJ Eby wrote: > > I mean that class-level __metaclass__ is no longer supported as of PEP > 3115, > > so I can't use that as a way to non-invasively obtain the enclosing > class at > > class creation time. > > Depe

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread PJ Eby
On Mon, Jun 4, 2012 at 10:25 PM, Nick Coghlan wrote: > On Tue, Jun 5, 2012 at 10:10 AM, PJ Eby wrote: > > On Mon, Jun 4, 2012 at 7:18 PM, Nick Coghlan wrote: > >> > >> On Tue, Jun 5, 2012 at 8:58 AM, PJ Eby wrote: > >> > On Mon, Jun 4, 2012 at 6:15 PM, Nick Coghlan > wrote: > >> >> > >> >> It

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread Eric Snow
On Mon, Jun 4, 2012 at 6:10 PM, PJ Eby wrote: > I mean that class-level __metaclass__ is no longer supported as of PEP 3115, > so I can't use that as a way to non-invasively obtain the enclosing class at > class creation time. Depends on what you mean by non-invasive: * http://code.activestate.c

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 10:10 AM, PJ Eby wrote: > On Mon, Jun 4, 2012 at 7:18 PM, Nick Coghlan wrote: >> >> On Tue, Jun 5, 2012 at 8:58 AM, PJ Eby wrote: >> > On Mon, Jun 4, 2012 at 6:15 PM, Nick Coghlan wrote: >> >> >> >> It's actually the pre-decoration class, since the cell is initialised >>

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread PJ Eby
On Mon, Jun 4, 2012 at 7:18 PM, Nick Coghlan wrote: > On Tue, Jun 5, 2012 at 8:58 AM, PJ Eby wrote: > > On Mon, Jun 4, 2012 at 6:15 PM, Nick Coghlan wrote: > >> > >> It's actually the pre-decoration class, since the cell is initialised > >> before the class is passed to the first decorator. I a

Re: [Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread Ethan Furman
Nick Coghlan wrote: On Tue, Jun 5, 2012 at 8:58 AM, PJ Eby wrote: The reason for wanting this to be transparent is that 1) if you forget the redundant class-decorator, mixin, or metaclass, stuff will silently not work, Why would it silently not work? What's preventing you from having decorator

[Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

2012-06-04 Thread Nick Coghlan
On Tue, Jun 5, 2012 at 8:58 AM, PJ Eby wrote: > On Mon, Jun 4, 2012 at 6:15 PM, Nick Coghlan wrote: >> >> It's actually the pre-decoration class, since the cell is initialised >> before the class is passed to the first decorator. I agree it's a little >> weird, but I did try to describe it accura