I know that the parameters can be any object but for the documentation it is quite important to specify what you would expect.

First is how to specify a parameter types like these below?

str (or use String or string?)

int

list

dict

function()

tuple

object instance of class MyClass

Second, how to specify params that can be of multiple types like a function that can handle a single parameter than can be int or str?

Please use the below example to demonstrate the syntax needed for documenting this with your proposed solution. Mind that it is desired to be able to hyperlink reference to the "Image" class from inside the documentation.

def myMethod(self, name, image):

"""

Does something ...

name String: name of the image

image Image: instance of Image Class or a string indicating the filename.

Return True if operation succeeded or False.

"""

return True

Note, you are welcome to suggest the usage of any documentation tool (sphinx, oxygen, ...) as long it is able to deal with the requirements.

Update:

It seams that there is some kind of support for documenting parameter types in doxygen in. general. The code below works but adds an annoying $ to the param name (because it was initially made for php).

@param str $arg description

@param str|int $arg description

解决方案

There is a better way. We use

def my_method(x, y):

"""

my_method description

@type x: int

@param x: An integer

@type y: int|string

@param y: An integer or string

@rtype: string

@return: Returns a sentence with your variables in it

"""

return "Hello World! %s, %s" % (x,y)

That's it. In the PyCharm IDE this helps a lot. It works like a charm ;-)

python函数支持哪些参数类型_如何记录python函数参数类型?相关推荐

  1. 不显示参数名_第51p,万能参数与返回值,Python中函数的返回值

    大家好,我是杨数Tos,这是<从零基础到大神>系列课程的第51篇文章,第三阶段的课程:Python进阶知识:详细讲解Python中的函数(四)====>函数的参数与返回值(下篇). ...

  2. python函数定义中参数列表里的参数是_详解Python函数中参数带星号是什么意思

    函数的参数使用除了常规的位置参数和关键字参数外,还支持可变个数的函数参数,这种支持可变个数的参数方法称为参数收集,对应的参数称为收集参数. 一.参数收集的定义 Python的函数支持可变不定数量的参数 ...

  3. 中boxplot函数的参数设置_如何在Python中生成图形和图表

    在本章中,我们将学习如何在Python中生成图形和图表,同时将使用函数和面向对象的方法来可视化数据. Python中常用的一些可视化数据包括以下几种. Matplotlib. Seaborn. ggp ...

  4. len函数python返回值类型_简单介绍Python中的len()函数的使用

    01状态机介绍 游戏中的状态机一般都是有限状态机,简写为FSM(有限状态机),简称状态机,是表示有限个状态以及在这些状态之间的转移和动作等行为的数学模型. 状态机的每一个状态至少需要有以下三个操作: ...

  5. python中 是什么类型_浅谈python中的变量默认是什么类型

    浅谈python中的变量默认是什么类型 1.type(变量名),输出的结果就是变量的类型: 例如 >>> type(6) 2.在Python里面变量在声明时,不需要指定变量的类型,变 ...

  6. pythonnamedtuple定义类型_详解Python中namedtuple的使用

    namedtuple是Python中存储数据类型,比较常见的数据类型还有有list和tuple数据类型.相比于list,tuple中的元素不可修改,在映射中可以当键使用. namedtuple: na ...

  7. python 判断类型_青少年之Python编程课程安排lt;第一季gt;

    第一章    开启Python之旅 1.   你将了解什么是Python 2.   在电脑上安装并简单使用Python 3.   开始通过Python与计算机进行交流(编程) 第二章    变量 1. ...

  8. python用可变参数求积_流畅的python读书笔记-第八章-对象引用、可变性和垃圾回收...

    对象不是个盒子 class Gizmo: def __init__(self): print('Gizmo id: %d' % id(self)) x = Gizmo() print(x) y = G ...

  9. python不支持以下哪种数据类型_下列数据类型中, Python不支持的是()。_学小易找答案...

    [判断题]a={},type(a)结果是 . (5.0分) [简答题]内造型设计 [填空题]水分子之间存在着质子的传递作用,称为水的 作用,这个作用的平衡常数在25度时等于 . [填空题]len('3 ...

  10. python 类初始化参数校验_如何规避python参数的初始化次数?

    我们在内存不足的时候,除了增加内存的可用度,可以进行一个清理内存的初始化操作,当然这种是最后迫不得已的选择.我们在python中也有需要用到初始化的地方,鉴于参数和函数的关系密不可分,本篇我们会简单的 ...

最新文章

  1. js数组中的splice()方法
  2. 我的第一个纯手写jQuery插件
  3. C语言程序设计:现代方法(第2版)第三章全部习题答案
  4. 点击关闭按钮时缩小到系统任务栏
  5. linux中的bash shell的特性
  6. python 找到目录下文件名规则_Python学习第162课--PATH变量值修改以及模糊查找文件名...
  7. Linux 命令之 pwconv -- 开启用户的投影密码
  8. java oracle的枚举错误
  9. ubtunu打开firefox_如何在Firefox(在Lubuntu中)中打开“apt”链接?
  10. 关于深度学习,我们4年时间写了一本1400页的全栈手册
  11. 实时获取滚动条的高度_适用于星上快速处理的雷达高度计有效波高反演技术
  12. Java中抽象类和接口的区别(来源一)
  13. 下一站,人到三十而立之年有感!
  14. 99数据集预处理_深度学习在放射治疗的应用—工具篇(五)数据集构建
  15. 用上帝视角来看待组件的设计模式
  16. github是干什么的_GitHub排名第一!免费最强“抢票神器”在手,程序员抢票不愁
  17. PS利用色彩范围抠图
  18. java 裁剪 pdf_java拆分pdf文档
  19. 20210319_23期_心跳检测_Task02_数据探索性分析
  20. php 前后端分离之rsa与des加密之旅

热门文章

  1. 利用Linq对集合元素合并、去重复处理
  2. windows 不能确定用户和计算机名称
  3. js-数据类型和变量
  4. 15.看板方法---启动看板变革
  5. 7.看板方法---使用看板进行协调
  6. 97. PATH_SEPARATOR 和 DIRECTORY_SEPARATOR
  7. 18. Magento 细节
  8. Mybatis中传参包There is no getter for property named 'XXX' in 'c
  9. 【模拟】Workout for a Dumbbell
  10. mac+nginx+php70+mysql环境搭建