can not find a default python_《Learn Python》学习笔记

Part 3 || Chapter 15 Python Docs

========================

1. Where can find Python Docs resources ?

Comment in Python file  : # this is a single line comment.

dir() :

docstring : __doc__

Python Doc : help()

Standard manual set

Web Resources / Books

2. How to get detailed information about the attributes of an object ?

__doc__ : module docstring is on the *.py head; function and class docstring place in head in

function / class body respectively.

Eg. Module.__doc__; Module.func.__doc__;Module.cls.__doc__;Module.cls.method.__doc__;

help() : Auto generate module info in specific way.

Python Module Document : all

=======================================

Part 3 : practice

=======================================

Part 4 || Chapter 16  Function Basics

0. function is  a packaged procedure invoked by its name,

functions are also basic program structure Python provide for maximizing

code reuse,which split complex complex systems into manageable parts.

declare function        -->  def / lambda

scope visibility          -->  global / nonlocal

come results              -->  return / yield

1.How to create function ?

def statements are coded in module files and run to generate functions when

the module file first imported.

def create an function object and assigns it to a name [function name]

lambda  create an object but return it as a result.

return sends a result object back to caller. A return without a value will return

None,the default value.

yield send a result object back to the caller,but remember where it left off.[generators]

2. Variable Visibility Scope

global declare module-level variables that are to be assigned,which can be used to retain

state - information remembered between functions call,without by sharing

global names.

Function's arguments ,return values and variables are not declare and no type constraints,

which mean that they can be any types.

function definition happens at Python runtime.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值