One option is a list comprehension:
[add(x, 2) for x in [1, 2, 3]]
More options:
a = [1, 2, 3]
import functools
map(functools.partial(add, y=2), a)
import itertools
map(add, a, itertools.repeat(2, len(a)))
Related Contents:
- Remap values in pandas column with a dict, preserve NaNs
- What’s the difference between eval, exec, and compile?
- How to merge dictionaries of dictionaries?
- How does exec work with locals?
- multiprocessing global variable updates not returned to parent
- Append multiple pandas data frames at once
- Confused about backslashes in regular expressions [duplicate]
- What are the arguments to Tkinter variable trace method callbacks?
- Different behaviour for list.__iadd__ and list.__add__
- How do I install Python packages on Windows?
- How to use subprocess popen Python [duplicate]
- Lost connection to MySQL server during query
- What is the use of join() in Python threading?
- What is the difference between flatten and ravel functions in numpy?
- Windows is not passing command line arguments to Python programs executed from the shell
- Check if string ends with one of the strings from a list
- Running an outside program (executable) in Python?
- AttributeError: ‘module’ object has no attribute ‘urlopen’
- Using moviepy, scipy and numpy in amazon lambda
- Python subprocess.Popen “OSError: [Errno 12] Cannot allocate memory”
- Named regular expression group “(?Pregexp)”: what does “P” stand for?
- What is the __dict__.__dict__ attribute of a Python class?
- How do I make my player rotate towards mouse position?
- Appending item to lists within a list comprehension
- SQL-like window functions in PANDAS: Row Numbering in Python Pandas Dataframe
- multiprocessing vs multithreading vs asyncio in Python 3
- Suppress InsecureRequestWarning: Unverified HTTPS request is being made in Python2.6
- How to convert defaultdict to dict?
- Statistics: combinations in Python
- Why can’t you add attributes to object in python? [duplicate]
- Format strings vs concatenation
- How to print a list with integers without the brackets, commas and no quotes? [duplicate]
- Use Django ORM as standalone [duplicate]
- Why does termcolor output control characters instead of colored text in the Windows console?
- How to get the return value of a function passed to multiprocessing.Process?
- How do I detect whether a variable is a function?
- DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
- How to safely write to a file?
- Selecting/excluding sets of columns in pandas [duplicate]
- PIL rotate image colors (BGR -> RGB)
- Converting to (not from) ipython Notebook format
- Retrieve XY data from matplotlib figure [duplicate]
- Removing Punctuation From Python List Items
- Group list by values [duplicate]
- Compress numpy arrays efficiently
- Subtracting numpy arrays of different shape efficiently
- Cython class AttributeError
- Python: No csv.close()?
- Map dataframe index using dictionary
- How do I convert a tuple of tuples to a one-dimensional list using list comprehension? [duplicate]