← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 james
收信人 Guido.van.Rossum, dirn, eric.araujo, eric.smith, eric.snow, gvanrossum, james, ncoghlan, peyton
日期 2013-11-21.01:36:20
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1384997782.98.0.228351558707.issue19660@psf.upfronthosting.co.za>
In-reply-to
内容
I see this as removing a restriction and a special-case from the
decorator syntax (noting, of course, that these were introduced
deliberately.)

In terms of whether the new forms are improvements, my preference is to
leave this up to the judgement of the programmer, moderated of course by
their prevailing coding guide.

I would argue that this change does not force any additional complexity
on the programmer (who is free to take or leave it) or on the
interpreter (- the straightforwardness of the patch corroborates this.)

I would also argue that there are certainly cases where, in the midst of
some large codebase, the dotted_name restriction may seem a bit arbitrary.

This is likely true for:

class Foo:
    def bar(self, func):
        return func

    @staticmethod
    def baz(func):
        return func
	
    @staticmethod
    def quux():
        def dec(func):
            return func
        return dec

# invalid
@Foo().bar
def f(): pass

# valid
@Foo.baz
def f(): pass

# valid
@Foo.quux()
def f(): pass

For completeness' sake, I have attached a patch with an additional unit
test and amended documentation.

Should we proceed with writing a PEP for Python 3.5?
历史
日期 用户 动作 参数
2013-11-21 01:36:23james修改recipients: + james, gvanrossum, ncoghlan, eric.smith, eric.araujo, eric.snow, dirn, Guido.van.Rossum, peyton
2013-11-21 01:36:22james修改messageid: <1384997782.98.0.228351558707.issue19660@psf.upfronthosting.co.za>
2013-11-21 01:36:22james链接issue19660 messages
2013-11-21 01:36:22james创建