How to specify argument type in a dynamically typed language, i.e. Python?

后端 未结 5 1637
甜味超标
甜味超标 2021-01-23 13:11

Is there any such equivalent of Java

String myMethod (MyClass argument) {...}

in Python?

Thank you, Tomas

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-23 13:44

    No, there is not.

    In fact, checking types is considered "un-Pythonic", because an object of any type that looks enough like the expected type should be treated equally.

提交回复
热议问题