This is called currying, or partial application. You can use the built-in functools.partial(). Something like the following would do what you want.
import functools
def add(x,y):
return x + y
inc2 = functools.partial(add, 2)
print inc2(3)
More Related Contents:
- Using lambda function in python
- Python 2.7.10: Using LAMBDA and LOGICAL operators in DICT to choose a case
- Sum of multiples of two numbers
- lambda in for loop only takes last value [duplicate]
- Python lambda’s binding to local values
- Finding the average of a list
- Python lambda closure scoping
- How do I create a list of lambdas (in a list comprehension/for loop)?
- Python: calling ‘list’ on a map object twice
- List comprehension vs. lambda + filter
- Using lambda expression to connect slots in pyqt
- Which is more preferable to use: lambda functions or nested functions (‘def’)?
- Assignment inside lambda expression in Python
- List comprehension and lambdas in Python [duplicate]
- E731 do not assign a lambda expression, use a def
- Why doesn’t print work in a lambda?
- Weird behavior: Lambda inside list comprehension [duplicate]
- No Multiline Lambda in Python: Why not?
- what is the difference for python between lambda and regular function?
- Check if two Python functions are equal
- lambda arguments unpack error
- Use value of variable in lambda expression [duplicate]
- What is `lambda` in Python code? How does it work with `key` arguments to `sorted`, `sum` etc.?
- Python lambda does not accept tuple argument [duplicate]
- What does “lambda” mean in Python, and what’s the simplest way to use it?
- Why do parentheses in a lambda function cause syntax error on Python 3? [duplicate]
- Why use lambda functions?
- How to use await in a python lambda
- What exactly is “lambda” in Python? [duplicate]
- Python one-line “for” expression [duplicate]