美文网首页
《Learn Python》学习笔记

《Learn Python》学习笔记

作者: Dokkii | 来源:发表于2018-09-21 16:43 被阅读0次


    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.

    相关文章

      网友评论

          本文标题:《Learn Python》学习笔记

          本文链接:https://www.haomeiwen.com/subject/alcznftx.html