Are decorators really that different from metaclasses...
aleaxit at yahoo.com
Mon Aug 30 10:07:39 CEST 2004
Paul Morrow <pm_mon at yahoo.com> wrote:
> Alex Martelli wrote:
> > Paul Morrow <pm_mon at yahoo.com> wrote:
> > ...
> >>Cool! Thanks! Now I need to ponder why a function's docstring needs a
> >>different implementation than a class's docstring (i.e. why not just
> >>make it a straigtforward attribute of the function object).
> > Historically, functions had docstrings before they had straightforward
> > attributes. Maybe it could be that.
> > Alex
> I have stared at your reply for three or four minutes now. On the
> surface, it seems that you are being genuinely helpful, and so I want to
> reply "Thanks. Of course. That makes perfect sense."
Heh, I think you've wasted a few minutes here.
> But then a lot of smart people say things that (on the surface) appear
> honestly helpful but in reality are suggestions that the reader do more
> research before asking questions that have such an obvious answer.
Doing your own research is good, of course. But once you have, there's
no harm checking your conclusions on mailing lists. Functions had a few
_non_-straightforward attributes (such as func_doc AKA __doc__ -- and I
don't recall which one came first) for a long time before they got
straightforward (==implemented with a dict) ones, after all.
> I know that you're a smart person Mr. Martelli. So I flipped a coin to
> decide which intreprtation of your reply to use, which came up tails,
> indicating the 2nd one.
> Bahh. I prefer the superficial one (plz correct me if I'm wrong).
> Thanks. That does make good sense. They've had no reason to simplify
> the implementation for function docstrings, so "why fix it if it ain't
Many object types have 'slots' ("non straightforward attributes") as
well as possibly a per-instance dict in which they may keep other
(straightforward) attributes. I see no reason why moving attributes
from dedicated slots to a dictionary should be a simplification. Take
attribute __name__: that's not in the dict for either functions or
classes (in functions, it's also known as func_name). Why not?
More information about the Python-list