Is this PEP-able? (syntax for functools.partial-like functionality)

Steven D'Aprano steve at pearwood.info
Tue Aug 20 02:16:48 EDT 2013


On Tue, 20 Aug 2013 00:49:16 +0100, Fábio Santos wrote:

> I had an idea for a handy syntax which I thought of while designing a
> language for fun. This would be a syntax for creating, from a function,
> a function which is just like it but with some parameters pre-filled.
> The usage is much like functools.partials, and my proposed syntax is
> like this:
> 
> def spam(a, b, c):
>     ...
> 
> spam_with_defaults = spam{1, 2}


Handy it may be, but why is this usage important enough to deserve new 
syntax? The barrier to entry for new syntax is very high. For example, 
Enums are a common, and standard, feature in many programming languages. 
Enums will be introduced to Python in 3.4, but even they don't get 
special syntax.



-- 
Steven



More information about the Python-list mailing list