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-August/046904.html below:

[Python-Dev] Call for defense of @decorators

[Python-Dev] Call for defense of @decoratorsGustavo Niemeyer niemeyer at conectiva.com
Thu Aug 5 21:17:10 CEST 2004
Hi Bob,

> >Why are they special? Why should they be more important than any other
> >part of the function definition?
> 
> Because they take a function object as input and can do whatever they 
> want with it and return something else.

This seems extremely powerful. OTOH, perl is also powerful.

> >>def saveSheetDidDismiss_returnCode_contextInfo_(self, sheet,
> 
> >What is objc.signature() doing?
> 
> objc.signature wraps the function object with an objc.selector that 
> specifies specific return and argument types.  In this particular case, 
> it declares that the selector 
> saveSheetDidDismiss:returnCode:contextInfo: returns void and takes an 
> object and an integer as arguments.  Without this, the selector can not 
> be bridged correctly to the Objective C runtime and the program would 
> crash.

Isn't metaclass usage helpful in this case?

Or a perhaps a dictionary?

   __signature__ = {"funcname": "v@:@i"}

or

   def funcname(...):
      ...
   funcname.signature = "v@:@i"

and a postprocessor like:

objc.register(classname)

> The ctypes package behaves similarly and would use decorators for the 
> same thing.  I imagine that other runtime/language bridges would also 
> benefit from similar techniques (Jython, IronPython, Python.NET, 
> JPython.. or whatever else).  I can also imagine it being used for 
> things like XML-RPC, SOAP, Apple Events, COM, etc. in a similar manner.

Is this something good? I mean, having function wrappers all
around the place? Wouldn't it be introducing unobvious code (magic?)
in packages which are working fine as they are?

Should I just throw away my t-shirt with the "zen of python" text? :-)

-- 
Gustavo Niemeyer
http://niemeyer.net
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