What is the use of duck typing?

What is the use of duck typing?
A. More restriction on the type values that can be passed to a given method
B. No restriction on the type values that can be passed to a given method
C. Less restriction on the type values that can be passed to a given method
D. Makes the program code smaller
 
Answer: c
Explanation: In Python, any set of classes with a common set of methods can be treated similarly. This is called duck typing. Hence duck typing imposes less restrictions.
 

Tìm kiếm

Back
Top