zoukankan      html  css  js  c++  java
  • 4.内置函数源码总结

      1 def abs(*args, **kwargs):  # real signature unknown
      2     """ Return the absolute value of the argument. """
      3     pass
      4 #abs(*args, **kwargs)#返回参数的绝对值,可接收任何数据类型
      5 #?绝对值如何接收数值意外的类型得到什么样的结果。(报错,应该是不可接收)
      6 
      7 def all(*args, **kwargs):  # real signature unknown
      8     """
      9     Return True if bool(x) is True for all values x in the iterable.
     10 
     11     If the iterable is empty, return True.
     12     """
     13     pass
     14 
     15 
     16 def any(*args, **kwargs):  # real signature unknown
     17     """
     18     Return True if bool(x) is True for any x in the iterable.
     19 
     20     If the iterable is empty, return False.
     21     """
     22     pass
     23 
     24 
     25 def ascii(*args, **kwargs):  # real signature unknown
     26     """
     27     Return an ASCII-only representation of an object.
     28 
     29     As repr(), return a string containing a printable representation of an
     30     object, but escape the non-ASCII characters in the string returned by
     31     repr() using \x, \u or \U escapes. This generates a string similar
     32     to that returned by repr() in Python 2.
     33     """
     34     pass
     35 
     36 
     37 def bin(*args, **kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__
     38     """
     39     Return the binary representation of an integer.
     40 
     41        >>> bin(2796202)
     42        '0b1010101010101010101010'
     43     """
     44     pass
     45 
     46 
     47 def callable(i_e_, some_kind_of_function):  # real signature unknown; restored from __doc__
     48     """
     49     Return whether the object is callable (i.e., some kind of function).
     50 
     51     Note that classes are callable, as are instances of classes with a
     52     __call__() method.
     53     """
     54     pass
     55 
     56 
     57 def chr(*args, **kwargs):  # real signature unknown
     58     """ Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. """
     59     pass
     60 
     61 
     62 def compile(*args, **kwargs):  # real signature unknown
     63     """
     64     Compile source into a code object that can be executed by exec() or eval().
     65 
     66     The source code may represent a Python module, statement or expression.
     67     The filename will be used for run-time error messages.
     68     The mode must be 'exec' to compile a module, 'single' to compile a
     69     single (interactive) statement, or 'eval' to compile an expression.
     70     The flags argument, if present, controls which future statements influence
     71     the compilation of the code.
     72     The dont_inherit argument, if true, stops the compilation inheriting
     73     the effects of any future statements in effect in the code calling
     74     compile; if absent or false these statements do influence the compilation,
     75     in addition to any features explicitly specified.
     76     """
     77     pass
     78 
     79 
     80 def copyright(*args, **kwargs):  # real signature unknown
     81     """
     82     interactive prompt objects for printing the license text, a list of
     83         contributors and the copyright notice.
     84     """
     85     pass
     86 
     87 
     88 def credits(*args, **kwargs):  # real signature unknown
     89     """
     90     interactive prompt objects for printing the license text, a list of
     91         contributors and the copyright notice.
     92     """
     93     pass
     94 
     95 
     96 def delattr(x, y):  # real signature unknown; restored from __doc__
     97     """
     98     Deletes the named attribute from the given object.
     99 
    100     delattr(x, 'y') is equivalent to ``del x.y''
    101     """
    102     pass
    103 
    104 
    105 def dir(p_object=None):  # real signature unknown; restored from __doc__
    106     """
    107     dir([object]) -> list of strings
    108 
    109     If called without an argument, return the names in the current scope.
    110     Else, return an alphabetized list of names comprising (some of) the attributes
    111     of the given object, and of attributes reachable from it.
    112     If the object supplies a method named __dir__, it will be used; otherwise
    113     the default dir() logic is used and returns:
    114       for a module object: the module's attributes.
    115       for a class object:  its attributes, and recursively the attributes
    116         of its bases.
    117       for any other object: its attributes, its class's attributes, and
    118         recursively the attributes of its class's base classes.
    119     """
    120     return []
    121 
    122 
    123 def divmod(x, y):  # known case of builtins.divmod
    124     """ Return the tuple (x//y, x%y).  Invariant: div*y + mod == x. """
    125     return (0, 0)
    126 
    127 
    128 def eval(*args, **kwargs):  # real signature unknown
    129     """
    130     Evaluate the given source in the context of globals and locals.
    131 
    132     The source may be a string representing a Python expression
    133     or a code object as returned by compile().
    134     The globals must be a dictionary and locals can be any mapping,
    135     defaulting to the current globals and locals.
    136     If only globals is given, locals defaults to it.
    137     """
    138     pass
    139 
    140 
    141 def exec(*args, **kwargs):  # real signature unknown
    142     """
    143     Execute the given source in the context of globals and locals.
    144 
    145     The source may be a string representing one or more Python statements
    146     or a code object as returned by compile().
    147     The globals must be a dictionary and locals can be any mapping,
    148     defaulting to the current globals and locals.
    149     If only globals is given, locals defaults to it.
    150     """
    151     pass
    152 
    153 
    154 def exit(*args, **kwargs):  # real signature unknown
    155     pass
    156 
    157 
    158 def format(*args, **kwargs):  # real signature unknown
    159     """
    160     Return value.__format__(format_spec)
    161 
    162     format_spec defaults to the empty string
    163     """
    164     pass
    165 
    166 
    167 def getattr(object, name, default=None):  # known special case of getattr
    168     """
    169     getattr(object, name[, default]) -> value
    170 
    171     Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
    172     When a default argument is given, it is returned when the attribute doesn't
    173     exist; without it, an exception is raised in that case.
    174     """
    175     pass
    176 
    177 
    178 def globals(*args, **kwargs):  # real signature unknown
    179     """
    180     Return the dictionary containing the current scope's global variables.
    181 
    182     NOTE: Updates to this dictionary *will* affect name lookups in the current
    183     global scope and vice-versa.
    184     """
    185     pass
    186 
    187 
    188 def hasattr(*args, **kwargs):  # real signature unknown
    189     """
    190     Return whether the object has an attribute with the given name.
    191 
    192     This is done by calling getattr(obj, name) and catching AttributeError.
    193     """
    194     pass
    195 
    196 
    197 def hash(*args, **kwargs):  # real signature unknown
    198     """
    199     Return the hash value for the given object.
    200 
    201     Two objects that compare equal must also have the same hash value, but the
    202     reverse is not necessarily true.
    203     """
    204     pass
    205 
    206 
    207 def help():  # real signature unknown; restored from __doc__
    208     """
    209     Define the builtin 'help'.
    210 
    211         This is a wrapper around pydoc.help that provides a helpful message
    212         when 'help' is typed at the Python interactive prompt.
    213 
    214         Calling help() at the Python prompt starts an interactive help session.
    215         Calling help(thing) prints help for the python object 'thing'.
    216     """
    217     pass
    218 
    219 
    220 def hex(*args, **kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__
    221     """
    222     Return the hexadecimal representation of an integer.
    223 
    224        >>> hex(12648430)
    225        '0xc0ffee'
    226     """
    227     pass
    228 
    229 
    230 def id(*args, **kwargs):  # real signature unknown
    231     """
    232     Return the identity of an object.
    233 
    234     This is guaranteed to be unique among simultaneously existing objects.
    235     (CPython uses the object's memory address.)
    236     """
    237     pass
    238 
    239 
    240 def input(*args, **kwargs):  # real signature unknown
    241     """
    242     Read a string from standard input.  The trailing newline is stripped.
    243 
    244     The prompt string, if given, is printed to standard output without a
    245     trailing newline before reading input.
    246 
    247     If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
    248     On *nix systems, readline is used if available.
    249     """
    250     pass
    251 
    252 
    253 def isinstance(x, A_tuple):  # real signature unknown; restored from __doc__
    254     """
    255     Return whether an object is an instance of a class or of a subclass thereof.
    256 
    257     A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to
    258     check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B)
    259     or ...`` etc.
    260     """
    261     pass
    262 
    263 
    264 def issubclass(x, A_tuple):  # real signature unknown; restored from __doc__
    265     """
    266     Return whether 'cls' is a derived from another class or is the same class.
    267 
    268     A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to
    269     check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B)
    270     or ...`` etc.
    271     """
    272     pass
    273 
    274 
    275 def iter(source, sentinel=None):  # known special case of iter
    276     """
    277     iter(iterable) -> iterator
    278     iter(callable, sentinel) -> iterator
    279 
    280     Get an iterator from an object.  In the first form, the argument must
    281     supply its own iterator, or be a sequence.
    282     In the second form, the callable is called until it returns the sentinel.
    283     """
    284     pass
    285 
    286 
    287 def len(*args, **kwargs):  # real signature unknown
    288     """ Return the number of items in a container. """
    289     pass
    290 
    291 
    292 def license(*args, **kwargs):  # real signature unknown
    293     """
    294     interactive prompt objects for printing the license text, a list of
    295         contributors and the copyright notice.
    296     """
    297     pass
    298 
    299 
    300 def locals(*args, **kwargs):  # real signature unknown
    301     """
    302     Return a dictionary containing the current scope's local variables.
    303 
    304     NOTE: Whether or not updates to this dictionary will affect name lookups in
    305     the local scope and vice-versa is *implementation dependent* and not
    306     covered by any backwards compatibility guarantees.
    307     """
    308     pass
    309 
    310 
    311 def max(*args, key=None):  # known special case of max
    312     """
    313     max(iterable, *[, default=obj, key=func]) -> value
    314     max(arg1, arg2, *args, *[, key=func]) -> value
    315 
    316     With a single iterable argument, return its biggest item. The
    317     default keyword-only argument specifies an object to return if
    318     the provided iterable is empty.
    319     With two or more arguments, return the largest argument.
    320     """
    321     pass
    322 
    323 
    324 def min(*args, key=None):  # known special case of min
    325     """
    326     min(iterable, *[, default=obj, key=func]) -> value
    327     min(arg1, arg2, *args, *[, key=func]) -> value
    328 
    329     With a single iterable argument, return its smallest item. The
    330     default keyword-only argument specifies an object to return if
    331     the provided iterable is empty.
    332     With two or more arguments, return the smallest argument.
    333     """
    334     pass
    335 
    336 
    337 def next(iterator, default=None):  # real signature unknown; restored from __doc__
    338     """
    339     next(iterator[, default])
    340 
    341     Return the next item from the iterator. If default is given and the iterator
    342     is exhausted, it is returned instead of raising StopIteration.
    343     """
    344     pass
    345 
    346 
    347 def oct(*args, **kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__
    348     """
    349     Return the octal representation of an integer.
    350 
    351        >>> oct(342391)
    352        '0o1234567'
    353     """
    354     pass
    355 
    356 
    357 def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None,
    358          closefd=True):  # known special case of open
    359     """
    360     Open file and return a stream.  Raise IOError upon failure.
    361 
    362     file is either a text or byte string giving the name (and the path
    363     if the file isn't in the current working directory) of the file to
    364     be opened or an integer file descriptor of the file to be
    365     wrapped. (If a file descriptor is given, it is closed when the
    366     returned I/O object is closed, unless closefd is set to False.)
    367 
    368     mode is an optional string that specifies the mode in which the file
    369     is opened. It defaults to 'r' which means open for reading in text
    370     mode.  Other common values are 'w' for writing (truncating the file if
    371     it already exists), 'x' for creating and writing to a new file, and
    372     'a' for appending (which on some Unix systems, means that all writes
    373     append to the end of the file regardless of the current seek position).
    374     In text mode, if encoding is not specified the encoding used is platform
    375     dependent: locale.getpreferredencoding(False) is called to get the
    376     current locale encoding. (For reading and writing raw bytes use binary
    377     mode and leave encoding unspecified.) The available modes are:
    378 
    379     ========= ===============================================================
    380     Character Meaning
    381     --------- ---------------------------------------------------------------
    382     'r'       open for reading (default)
    383     'w'       open for writing, truncating the file first
    384     'x'       create a new file and open it for writing
    385     'a'       open for writing, appending to the end of the file if it exists
    386     'b'       binary mode
    387     't'       text mode (default)
    388     '+'       open a disk file for updating (reading and writing)
    389     'U'       universal newline mode (deprecated)
    390     ========= ===============================================================
    391 
    392     The default mode is 'rt' (open for reading text). For binary random
    393     access, the mode 'w+b' opens and truncates the file to 0 bytes, while
    394     'r+b' opens the file without truncation. The 'x' mode implies 'w' and
    395     raises an `FileExistsError` if the file already exists.
    396 
    397     Python distinguishes between files opened in binary and text modes,
    398     even when the underlying operating system doesn't. Files opened in
    399     binary mode (appending 'b' to the mode argument) return contents as
    400     bytes objects without any decoding. In text mode (the default, or when
    401     't' is appended to the mode argument), the contents of the file are
    402     returned as strings, the bytes having been first decoded using a
    403     platform-dependent encoding or using the specified encoding if given.
    404 
    405     'U' mode is deprecated and will raise an exception in future versions
    406     of Python.  It has no effect in Python 3.  Use newline to control
    407     universal newlines mode.
    408 
    409     buffering is an optional integer used to set the buffering policy.
    410     Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
    411     line buffering (only usable in text mode), and an integer > 1 to indicate
    412     the size of a fixed-size chunk buffer.  When no buffering argument is
    413     given, the default buffering policy works as follows:
    414 
    415     * Binary files are buffered in fixed-size chunks; the size of the buffer
    416       is chosen using a heuristic trying to determine the underlying device's
    417       "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`.
    418       On many systems, the buffer will typically be 4096 or 8192 bytes long.
    419 
    420     * "Interactive" text files (files for which isatty() returns True)
    421       use line buffering.  Other text files use the policy described above
    422       for binary files.
    423 
    424     encoding is the name of the encoding used to decode or encode the
    425     file. This should only be used in text mode. The default encoding is
    426     platform dependent, but any encoding supported by Python can be
    427     passed.  See the codecs module for the list of supported encodings.
    428 
    429     errors is an optional string that specifies how encoding errors are to
    430     be handled---this argument should not be used in binary mode. Pass
    431     'strict' to raise a ValueError exception if there is an encoding error
    432     (the default of None has the same effect), or pass 'ignore' to ignore
    433     errors. (Note that ignoring encoding errors can lead to data loss.)
    434     See the documentation for codecs.register or run 'help(codecs.Codec)'
    435     for a list of the permitted encoding error strings.
    436 
    437     newline controls how universal newlines works (it only applies to text
    438     mode). It can be None, '', '
    ', '
    ', and '
    '.  It works as
    439     follows:
    440 
    441     * On input, if newline is None, universal newlines mode is
    442       enabled. Lines in the input can end in '
    ', '
    ', or '
    ', and
    443       these are translated into '
    ' before being returned to the
    444       caller. If it is '', universal newline mode is enabled, but line
    445       endings are returned to the caller untranslated. If it has any of
    446       the other legal values, input lines are only terminated by the given
    447       string, and the line ending is returned to the caller untranslated.
    448 
    449     * On output, if newline is None, any '
    ' characters written are
    450       translated to the system default line separator, os.linesep. If
    451       newline is '' or '
    ', no translation takes place. If newline is any
    452       of the other legal values, any '
    ' characters written are translated
    453       to the given string.
    454 
    455     If closefd is False, the underlying file descriptor will be kept open
    456     when the file is closed. This does not work when a file name is given
    457     and must be True in that case.
    458 
    459     A custom opener can be used by passing a callable as *opener*. The
    460     underlying file descriptor for the file object is then obtained by
    461     calling *opener* with (*file*, *flags*). *opener* must return an open
    462     file descriptor (passing os.open as *opener* results in functionality
    463     similar to passing None).
    464 
    465     open() returns a file object whose type depends on the mode, and
    466     through which the standard file operations such as reading and writing
    467     are performed. When open() is used to open a file in a text mode ('w',
    468     'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open
    469     a file in a binary mode, the returned class varies: in read binary
    470     mode, it returns a BufferedReader; in write binary and append binary
    471     modes, it returns a BufferedWriter, and in read/write mode, it returns
    472     a BufferedRandom.
    473 
    474     It is also possible to use a string or bytearray as a file for both
    475     reading and writing. For strings StringIO can be used like a file
    476     opened in a text mode, and for bytes a BytesIO can be used like a file
    477     opened in a binary mode.
    478     """
    479     pass
    480 
    481 
    482 def ord(*args, **kwargs):  # real signature unknown
    483     """ Return the Unicode code point for a one-character string. """
    484     pass
    485 
    486 
    487 def pow(*args, **kwargs):  # real signature unknown
    488     """
    489     Equivalent to x**y (with two arguments) or x**y % z (with three arguments)
    490 
    491     Some types, such as ints, are able to use a more efficient algorithm when
    492     invoked using the three argument form.
    493     """
    494     pass
    495 
    496 
    497 def print(self, *args, sep=' ', end='
    ', file=None):  # known special case of print
    498     """
    499     print(value, ..., sep=' ', end='
    ', file=sys.stdout, flush=False)
    500 
    501     Prints the values to a stream, or to sys.stdout by default.
    502     Optional keyword arguments:
    503     file:  a file-like object (stream); defaults to the current sys.stdout.
    504     sep:   string inserted between values, default a space.
    505     end:   string appended after the last value, default a newline.
    506     flush: whether to forcibly flush the stream.
    507     """
    508     pass
    509 
    510 
    511 def quit(*args, **kwargs):  # real signature unknown
    512     pass
    513 
    514 
    515 def repr(obj):  # real signature unknown; restored from __doc__
    516     """
    517     Return the canonical string representation of the object.
    518 
    519     For many object types, including most builtins, eval(repr(obj)) == obj.
    520     """
    521     pass
    522 
    523 
    524 def round(number, ndigits=None):  # real signature unknown; restored from __doc__
    525     """
    526     round(number[, ndigits]) -> number
    527 
    528     Round a number to a given precision in decimal digits (default 0 digits).
    529     This returns an int when called with one argument, otherwise the
    530     same type as the number. ndigits may be negative.
    531     """
    532     return 0
    533 
    534 
    535 def setattr(x, y, v):  # real signature unknown; restored from __doc__
    536     """
    537     Sets the named attribute on the given object to the specified value.
    538 
    539     setattr(x, 'y', v) is equivalent to ``x.y = v''
    540     """
    541     pass
    542 
    543 
    544 def sorted(*args, **kwargs):  # real signature unknown
    545     """
    546     Return a new list containing all items from the iterable in ascending order.
    547 
    548     A custom key function can be supplied to customise the sort order, and the
    549     reverse flag can be set to request the result in descending order.
    550     """
    551     pass
    552 
    553 
    554 def sum(*args, **kwargs):  # real signature unknown
    555     """
    556     Return the sum of a 'start' value (default: 0) plus an iterable of numbers
    557 
    558     When the iterable is empty, return the start value.
    559     This function is intended specifically for use with numeric values and may
    560     reject non-numeric types.
    561     """
    562     pass
    563 
    564 
    565 def vars(p_object=None):  # real signature unknown; restored from __doc__
    566     """
    567     vars([object]) -> dictionary
    568 
    569     Without arguments, equivalent to locals().
    570     With an argument, equivalent to object.__dict__.
    571     """
    572     return {}
    573 
    574 
    575 def __build_class__(func, name, *bases, metaclass=None, **kwds):  # real signature unknown; restored from __doc__
    576     """
    577     __build_class__(func, name, *bases, metaclass=None, **kwds) -> class
    578 
    579     Internal helper function used by the class statement.
    580     """
    581     pass
    582 
    583 
    584 def __import__(name, globals=None, locals=None, fromlist=(), level=0):  # real signature unknown; restored from __doc__
    585     """
    586     __import__(name, globals=None, locals=None, fromlist=(), level=0) -> module
    587 
    588     Import a module. Because this function is meant for use by the Python
    589     interpreter and not for general use it is better to use
    590     importlib.import_module() to programmatically import a module.
    591 
    592     The globals argument is only used to determine the context;
    593     they are not modified.  The locals argument is unused.  The fromlist
    594     should be a list of names to emulate ``from name import ...'', or an
    595     empty list to emulate ``import name''.
    596     When importing a module from a package, note that __import__('A.B', ...)
    597     returns package A when fromlist is empty, but its submodule B when
    598     fromlist is not empty.  Level is used to determine whether to perform
    599     absolute or relative imports. 0 is absolute while a positive number
    600     is the number of parent directories to search relative to the current module.
    601     """
    602     pass

     知识扩展:

            Python_str_字符串_常用办法总结

            Python_list_常用方法总结

            Python dict_字典 常用办法总结

            Python_内置函数源码总结

            Python__魔法方法__总结

  • 相关阅读:
    C语言基础课程 第二课 HelloWorld不为菜鸟所知的秘密
    C语言基础课程 第一课 Linux环境配置小实战httpserver
    Linux企业级开发技术(6)——libevent企业级开发之内存管理
    Linux企业级开发技术(7)——libevent企业级开发之锁和线程
    Linux内存管理学习笔记--概述
    5月16日云栖精选夜读:从0到1构建大数据生态系列1:数据蛮荒中的拓荒之举
    luoguP1063 能量项链
    bzoj1060 [ZJOI2007]时态同步
    bzoj1864 [Zjoi2006]三色二叉树
    bzoj1864 [Zjoi2006]三色二叉树
  • 原文地址:https://www.cnblogs.com/pupilheart/p/9052274.html
Copyright © 2011-2022 走看看