python访问类中docstring注释的实现方法

yipeiwu_com6年前Python基础

本文实例讲述了python访问类中docstring注释的实现方法。分享给大家供大家参考。具体分析如下:

python的类注释是可以通过代码访问的,这样非常利于书写说明文档

class Foo:
  pass
class Bar:
  """Representation of a Bar"""
  pass
assert Foo.__doc__ == None
assert Bar.__doc__ == "Representation of a Bar"

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Queue 实现生产者消费者模型(实例讲解)

Python中,队列是线程间最常用的交换数据的形式。 Python Queue模块有三种队列及构造函数: 1、Python Queue模块的FIFO队列先进先出。 class Queue...

Python使用base64模块进行二进制数据编码详解

前言 昨天团队的学妹来问关于POP3协议的问题,所以今天稍稍研究了下POP3协议的格式和Python里面的poplib。而POP服务器往回传的数据里有一部分需要用到Base64进行解码,...

python、Matlab求定积分的实现

python、Matlab求定积分的实现

python求定积分 计算 from sympy import * x = symbols('x') print(integrate(sin(2*x)/(1+x**2), (x,...

Python定时任务APScheduler的实例实例详解

APScheduler 支持三种调度任务:固定时间间隔,固定时间点(日期),Linux 下的 Crontab 命令。同时,它还支持异步执行、后台执行调度任务。 一、基本架构 触发器...

python os.fork() 循环输出方法

先看下面这段代码: import os def main(): for i in range(0, 2): os.fork() print 'Hello'...