Function parameter types in Python
Posted
by Leif Andersen
on Stack Overflow
See other posts from Stack Overflow
or by Leif Andersen
Published on 2010-03-22T02:17:20Z
Indexed on
2010/03/22
2:21 UTC
Read the original article
Hit count: 449
Unless I'm mistaken, creating a function in python works like this
def my_func(param1, param2):
/*stuff*/
However, you don't actually give the types of those parameters. Also, if I remember, python is a strongly typed language, as such, it seams like python shouldn't let you pass in a parameter of a different type then the function creator expected. However, how does python know that the user of the function is passing in the proper types? Or will the program just die if it's the wrong type, assuming the function actually uses the parameter? Or do you have to specify the type/I'm missing something?
Thank you.
© Stack Overflow or respective owner