[Python] Un chiarimento sulla sintassi dell'Help integrato.

2020-02-19 Per discussione Gabriele Battaglia

Ciao a tutti.
Ho questa lista:

>>> l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14]
>>> l
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> l.index(8)
7

Tutto regolare fin qui.
Chiedo l'help sulla funzione list.index:

>>> help(l.index)
Help on built-in function index:

index(value, start=0, stop=2147483647, /) method of builtins.list instance
Return first index of value.

Raises ValueError if the value is not present.

>>> l.index(8, start=0)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: index() takes no keyword arguments
>>> l.index(8, start=0, stop=9)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: index() takes no keyword arguments

Domanda semplice, perchè non posso utilizzare le keywords specificate 
nell'help?


Oppure... So che se voglio cercare un valore in una porzione di lista 
scriverò:


l[3:10].index(8)

Ma il dubbio resta: come mai vengono riportate le keywords start and 
stop, nell'help?


Grazie in anticipo.

--
Gabriele Battaglia, IZ4APU (Libero)
Sent from TB on Windows 10, Genus Bononiae's computer.
___
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python


Re: [Python] Un chiarimento sulla sintassi dell'Help integrato.

2020-02-19 Per discussione Lorenzo Buonanno
Lo / alla fine degli argomenti indica che sono solo posizionali: non
possono essere passati come keyword

https://www.python.org/dev/peps/pep-0570/
___
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python


Re: [Python] Un chiarimento sulla sintassi dell'Help integrato.

2020-02-19 Per discussione Pietro Brunetti
TypeError: index() takes no keyword arguments
>
>
___
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python