Are decorators really that different from metaclasses...
Paul Morrow
pm_mon at yahoo.com
Sat Aug 28 09:47:38 EDT 2004
Jess Austin wrote:
> Paul Morrow <pm_mon at yahoo.com> wrote in message news:<mailman.2550.1093655878.5135.python-list at python.org>...
>
>>Jess Austin wrote:
>>
> Why didn't you respond to my detailed explanation of how binding and
> scoping work in Python? Would it be worth my time to restate the
> explanation in simpler terms?
>
>
I was going to, but couldn't really find one main idea in there to
respond to. It was a long paragraph full of lots and lots of complex
ideas, where many sentences had multiple interpretations. It seemed as
if, for almost every statement you made in that section, I would either
1) beg to differ, 2) reply that you were being imprecise in your
assertions, or 3) just not understand what you were talking about and
ask for you to explain what you meant.
If you would clearly restate the point you're trying to make, I'll
gladly try to respond to it.
>
>>>>Others seem to want to specify a function's metadata outside of the
>>>>function def, which just doesn't seem pythonic (IMO).
>>>
>>>
>>>If you really understood Python's scoping rules, you would know that
>>>this opinion is the opposite of the truth.
>>
>>A decorator is a kind of meta information. So are docstrings. The
>>proposals I've been seeing (A1 and J2 in particular) declare decorators
>>and docstrings outside of the function def (not inside of the function def).
>
>
> I'll be more specific. "Others seem to want to specify a function's
> metadata outside of the function def": truth. "which just doesn't
> seem pythonic": opposite of truth. "(IMO)": apparently truth.
> Pythonic is a word with a meaning (in this newsgroup anyway), and
> modifying an object's namespace from outside _is_ pythonic:
Really? Can you show me an example of this?
> we've
> always been able to do so (at least since mid-1999 when I started
> using python) and we always will be able to do so.
Just because we *can* do it doesn't make it Pythonic. To be Pythonic,
it must be beautiful (IMO). We can do lot's of things to an object from
outside of it's definition that are not Pythonic (IMO). Directly
updating it's __dict__ would be one example (IMO).
> Your proposed
> arbitrary character-driven change to Python's conventional scoping
> rules would _not_ be pythonic.
In your opinion.
> It may in fact be your opinion that
> such a change would be pythonic, but I correctly classified that
> opinion as the opposite of truth.
>
I don't know what classifying an "opinion as the opposite of truth"
means. Opinions are subjective assessments.
>
>
>>>Of all the current
>>>incarnations of function "metadata", only one may be set within the
>>>function, and that one is not set using a standard binding statement:
>>>
>>
>>True and True, provided that you believe that docstrings are the only
>>kind of function metadata. I believe though that attributes like
>>__author__ and __version__ above are also function metadata.
>
>
> Metadata is a programmer's convention, or perhaps in this case
> religious belief.
What? Metadata is a convention? Metadata is a belief?
> I'm not certain what your precise convention is
> since you haven't explained it.
I'm not suggesting a new coding convention. I'm suggesting that we
continue to us magic (__xxx__) attributes for all magic behavior.
> You evidently expect all
> "experienced" programmers to know it and respect it. Apparently it
> has something to do with underscore characters.
Yes I do. Yes it does.
Paul
More information about the Python-list
mailing list