[Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

Markus Meskanen markusmeskanen at gmail.com
Fri Feb 10 09:11:18 EST 2017


>
> I would like to add one more generic remark about syntax extensions,
> regarding something
> Markus said and which has bothered me before, also related to other syntax
> proposals.
>
> "Decorator approach is no different from doing `Foo.bar = bar` under the
> function definition I think, except it requires one to figure out what the
> decorator does first."
>
> My point would be that the new syntax *also* requires one to figure out
> what the new syntax does.
> And unfortunately, syntax is much less discoverable than decorators.
> For a decorator, I can do `help(decorator)' or search the python library
> reference or probably
> just mouse-hover over the name in my favourite editor/IDE.
>
> But if I don't understand the dot in `class foo.bar:', then what?
> It's probably somewhere buried in the language spec for `class' but
> realistically
> I am now going to blight Stackoverflow with my questions.
>

I deeply believe the dot notation is very simple to understand (for the
record, it's the default in JS ja Lua and they're not having any issues
with it), and I can't think of a situation where someone knows Python well
enough to understand decorators with arguments but wouldn't understand the
dot notation. We already use the dot notation for normal attributes, so why
not use it for attributes in function def? I think it'll be easier to
StackOverflow the dot notation as opposed to argumented decorators.

And what I meant by "they have to figure out what the decorator does first"
is that it varies between every project. You absolutely cannot know for
sure what the decorator does until you read through it, meaning you have to
go look it up everytime.

- Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170210/ba2cbb11/attachment.html>


More information about the Python-ideas mailing list