Are decorators really that different from metaclasses...
pm_mon at yahoo.com
Thu Aug 26 17:15:46 CEST 2004
Anthony Baxter wrote:
> On Thu, 26 Aug 2004 09:50:43 -0400, Paul Morrow <pm_mon at yahoo.com> wrote:
>>Ok. Then let's jettison the baggage with the word metadata and just
>>call them 'magic attributes'. It doesn't matter. The essential point
>>about them is that they almost /never have 'local variable' semantics/.
>>They are attributes of the object being defined. That's the point I'm
>>trying to drive home here. When we define __xxx__ attributes, we are
>>not intending to create local variables. No. We are making declarations.
> Explain to me how __getitem__ is a declaration while getMonkey is not,
> assuming both are methods.
> The only magic attribute that fits your case of "magic attribute" is
> The overwhelming number of double-under names are not magic
> attributes, or metadata, or whatever you want to call them.
__getitem__ is most certainly magical! Defining it 'declares'
(implicitly, but we'll ignore that governing zen rule for the moment)
that instances of the containing class have dictionary semantics (that
they can be used, in some degree, like dictionaries). That's magic.
That's meta. That's profoundly deeper than anything defining getMonkey
More information about the Python-list