Generics/templates in python?

前端 未结 10 1474
深忆病人
深忆病人 2020-12-22 19:16

How does python handle generic/template type scenarios? Say I want to create an external file \"BinaryTree.py\" and have it handle binary trees, but for any data type.

10条回答
  •  旧时难觅i
    2020-12-22 19:47

    Actually now you can use generics in Python 3.5+. See PEP-484 and typing module documentation.

    According to my practice it is not very seamless and clear especially for those who are familiar with Java Generics, but still usable.

提交回复
热议问题