Decorator syntax (was Re: PEP 318 - PyFIT comments)
mwh at python.net
Thu Aug 5 14:21:36 CEST 2004
"John Roth" <newsgroups at jhrothjr.com> writes:
> "Bruce Eckel" <BruceEckel at MailBlocks.com> wrote in message
> news:mailman.1168.1091667628.5135.python-list at python.org...
> > I'll weigh in a little on this one.
> > This is very similar to attributes/metadata in Java J2SE 5 and in C#.
> > The thing is, metadata is a little bit weird; it's intentionally
> > outside of the domain of the 'normal' programming language, because it
> > expresses things that you can't or shouldn't within the normal
> > programming language.
Except, of course, this is Python so there isn't any such thing as
metadata, really. Objects all the way down.
> > So you _do_ need an escape mechanism. And it also takes a little
> > bit of getting used to; it's orthogonal to what you normally think
> > of as a language feature. But the potential for metadata features,
> > at least in Java, is very powerful.
> I'd be a lot happier if it was, in fact, a general metadata
> facility. Unfortunately, it only seems to work on functions
> (methods), and for what I'm working on I need metadata for
> properties and fields as well, that is, any identifier that you can
> bind an object to.
Well, that would be because that's impossible :-) Where would you
attach the data in:
i = 0
You can't attach it to 'i' -- that's just a string. '0' is just an
integer. The class doesn't exist at the time the body is executed.
What you can do (today) of course is stuff like:
i = MagicProperty(int, default=0)
or something -- which obviously leaves ample space for metadata in the
argument list -- but that can be painful, I grant.
What kind of metadata do you want?
(I have to admit I read your first post on this thread a bit like
"this hammer doesn't do a very good job of screwing in screws" :-)
It is time-consuming to produce high-quality software. However,
that should not alone be a reason to give up the high standards
of Python development. -- Martin von Loewis, python-dev
More information about the Python-list