+ 1
Python functions
Why are functions written like this def customer (Id : int, phone : int) -> int What's the use of the colon in the argument? Why is there a -> int at the function declaration?
7 Respostas
+ 6
Slick I don't know for sure either, but I think this is the return type.
+ 3
Yup, seems like you coulda done that from the start, instead of letting us do that for you and then marking your own answer as best.
+ 2
the ": int" part is just to tell someone who's going over the code what type the parameter is. similar to c declaration
void print_somethin(char *buffer)
except the type is after. no idea about the "-> int"
EDIT: just looked it up and Gáá°á·á©áȘáȘ is right!
+ 1
Sudo
Ok according to this module, Id and phone are arguments and int is type of both arguments and -> int is return type.
0
I just checked it up and id : int is type hint while -> int is return type
Thanks Gáá°á·á©áȘáȘ Slick
0
Is this a python functions syntax. If so then in which version because I didn't find this type of function definition in python.
0
AÍąJ it's a syntax accompanied by typing module