You can achieve this with structural subtyping, such as Go interfaces and Python protocols. Whether that is desirable is a different question.