Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
Type "copyright", "credits" or "license" for more information.
IPython 7.8.0 -- An enhanced Interactive Python.
In [1]: x, y = 10, 20
In [2]: x, y
Out[2]: (10, 20)
In [3]: y, x = x, y
In [4]: def funzione( arg1, arg2 = None ):
...: print( arg1, arg2 )
...:
In [5]: funzione("pippo", "pluto")
pippo pluto
In [6]: funzione("pippo")
pippo None
In [7]: def argomenti_variabili(*argomenti):
...: print(argomenti)
...:
In [8]: argomenti_variabili()
()
In [9]: argomenti_variabili(1, 2, 3)
(1, 2, 3)
In [10]: def argomenti_fissi_e_variabili(uno, *argomenti):
...: print(argomenti, uno)
...:
In [11]: argomenti_fissi_e_variabili()
Traceback (most recent call last):
File "<ipython-input-11-b7a3464ccfc5>", line 1, in <module>
argomenti_fissi_e_variabili()
TypeError: argomenti_fissi_e_variabili() missing 1 required positional argument: 'uno'
In [12]:
In [12]: argomenti_fissi_e_variabili(1)
() 1
In [13]: argomenti_fissi_e_variabili(1, 2, 3)
(2, 3) 1
In [14]: lista = [ 1, 2, 3, 4]
In [15]: tuple(lista)
Out[15]: (1, 2, 3, 4)
In [16]: t = tuple(lista)
In [17]: list(t)
Out[17]: [1, 2, 3, 4]
In [18]: