A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-March/043590.html below:

[Python-Dev] method decorators (PEP 318)

[Python-Dev] method decorators (PEP 318) [Python-Dev] method decorators (PEP 318)Paul Prescod paul at prescod.net
Sat Mar 27 18:00:27 EST 2004
Russell Finn wrote:
> Mike Rovner wrote:
> 
> 
> I came up with nearly the same idea after reading Guido's original post, 
> except that I recommend using the existing dictionary literal syntax:
> 
> def func (args):
>     { author: "Guido", deprecated: True}
>     '''doc'''
>     pass
> 
> Perhaps this was just a typo in Mike's post.

What should happen in this case?

mod_author = "Guido"
author = 5

def func(self, author, mod_author):
	{ author: mod_author}

func("Paul", "Bill")

Does the func get:

	func.author = "Guido"

	or

	func.5 = "Guido"

	or

	func.Paul = "Bill"

	or

	...

A better solution is:

def func(self, author, mod_author){
	author: mod_author
	}:

Although this particular example is confusing because of the reused 
argument names, it is still reasonably clear that the decorator is 
evaluated at _definition time_ not _function run time_.

  Paul Prescod


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4