Does python have generic methods?

generics, python

Solution

No. Python is not a statically typed language, so there is no need for them. Java generics only provide compile time type safety; they don't do anything at runtime. Python doesn't have any compile time type safety, so it wouldn't make sense to add generics to beef up the compile time type checks Python doesn't have.

A list, for example, is an untyped collection. There is no equivalent of distinguishing between `List<Integer>` and `List<String>` because a Python list can store any type of object.

Problem

Does python have generic methods like Java? If so could you refer to a site that explains it.

Original source