Single/Double Star (/*) Parameters in Python
# Difference between *Parameter and **Parameter in Python
They both represent unrestricted in number of parameters inputs.
# Single Star Parameters
Single Star Parameter would save parameters as tuple.
def fun1(para1, *para2):
print(para1)
print(para2)
>>> fun1(1,2,3,4,5)
1
(2,3,4,5)
1
2
3
4
5
6
2
3
4
5
6
# Double Star parameters
Double Star parameters would save parameters as dictionary.
def fun2(para1, *para2):
print(para1)
print(para2)
>>> fun2(1, a=2, c=3)
1
{'a': 2, 'c':3}
1
2
3
4
5
6
2
3
4
5
6
Updated: 2021/09/15, 21:07:45
- 02
- Classmethod in Python09-15