Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

what is * in argument list in python

# It means that parameter(s) that comes after * are keyword only parameters.
# Consider the following:
def test(delay, result=None, *, loop=None):
    print(delay, result, loop)

'''
In this case, test(1,2,2) will raise TypeError since it is
expecting at most two positional arguments, i.e. delay and result:

test(1,2,2)
TypeError: test() takes from 1 to 2 positional arguments but 3 were given
'''

# The third argument, or loop, can only be assigned if used as keyword:
test(1,2,loop=2)
# 1 2 2
# Works fine
Comment

PREVIOUS NEXT
Code Example
Python :: python test coverage 
Python :: select each two elements on a list python 
Python :: plot dataframe 
Python :: for i in range 
Python :: python find closest date 
Python :: re.sub 
Python :: check if value in dictionary keys python dataframe 
Python :: pandas pivot tables 
Python :: tree implementation in python 
Python :: discord bot python 
Python :: take columns to rows in pandas 
Python :: python call function that need args with decorator 
Python :: How to check the number of occurence of each character of a given string in python 
Python :: change part of a text file python 
Python :: list insert python 
Python :: Create A Template In Django 
Python :: how to normalize scipy cross correlation 
Python :: python add list 
Python :: Excel file format cannot be determined, you must specify an engine manually 
Python :: sqlalchemy function for default value for column 
Python :: pytest monkeypatch 
Python :: python : a counter 
Python :: stack python 
Python :: all function in python 
Python :: map dataframe 
Python :: xml to python list in python 
Python :: python 2 
Python :: standard error of mean 
Python :: jupiter lab 
Python :: python pytest vs unittest 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =