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.

classification
Title: Add suport native Functor
Type: enhancement Stage: resolved
Components: None Versions: Python 3.4
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, rhettinger, yuriy_levchenko
Priority: normal Keywords:

Created on 2011-07-13 09:35 by yuriy_levchenko, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg140239 - (view) Author: yuriy_levchenko (yuriy_levchenko) Date: 2011-07-13 09:35
sample:

def foo(a,b):
 print a,b

foo(1,2)
fa = foo%(1)
fa(2)
fab = foo%(1,2)
fab()

result

12
12
12
msg140240 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-13 09:43
It's not entirely clear to me what you are proposing, but it looks like functools.partial[0].  Whatever it is, adding new syntax especially for it sounds highly unlikely. You might want to propose and discuss it on python-ideas though.

[0]: http://docs.python.org/library/functools.html#functools.partial
msg140325 - (view) Author: yuriy_levchenko (yuriy_levchenko) Date: 2011-07-14 10:30
http://www.python.org/dev/peps/pep-0309/#note

--------------------------------------------------------------------

Abandoned Syntax Proposal
 
I originally suggested the syntax fn@(*args, **kw), meaning the same as partial(fn, *args, **kw).
 
The @ sign is used in some assembly languages to imply register indirection, and the use here is also a kind of indirection. f@(x) is not f(x), but a thing that becomes f(x) when you call it.
 
It was not well-received, so I have withdrawn this part of the proposal. In any case, @ has been taken for the new decorator syntax

--------------------------------------------------------------------


Maybe change '@' -> '%'
msg140327 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-14 11:24
Using the func%(args) syntax is not possible because
fab = foo%(1,2)
is equivalent to
fab = foo.__mod__((1,2))

It might actually be possible to overload the % operator to make something that looks like your proposed syntax (without changing the actual Python syntax), but it still look hackish to me.
(We are also moving away from the % overload used by strings for the formatting in favor of the .format() method.)
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56757
2011-07-14 12:34:35r.david.murraysetstatus: open -> closed
2011-07-14 11:24:15ezio.melottisetmessages: + msg140327
2011-07-14 10:30:07yuriy_levchenkosetstatus: closed -> open

messages: + msg140325
2011-07-13 09:43:09ezio.melottisetstatus: open -> closed

nosy: + rhettinger, ezio.melotti
messages: + msg140240

resolution: rejected
stage: resolved
2011-07-13 09:35:27yuriy_levchenkocreate