我通常在Python中使用argparse,在R中使用docopt。我在argparse中遗漏的一个功能是为每个参数指定所需的数据类型。, help="display a square of a given number",在docopt / R中,我在文档中找不到任何关于需要特定数据类型的内容在Python版本的docopt Git
正确指定方法的参数类型的pythonic方法是什么?检查How do Python functions handle the types of the parameters that you pass in?和How do I ensure parameter is correct type in Python?仅适用于原始数据类型。 考虑下面的最小示例,其中我希望将一个相同类型的对象传递给该方法。这不起作用,因为该方法是在类中定义的