Type 8

0 views
Skip to first unread message

Ray Kowalewski

unread,
Aug 3, 2024, 5:16:54 PM8/3/24
to lucorespie

This calls the __anext__() method of async_iterator,returning an awaitable. Awaiting this returns the next value of theiterator. If default is given, it is returned if the iterator is exhausted,otherwise StopAsyncIteration is raised.

As repr(), return a string containing a printable representation of anobject, but escape the non-ASCII characters in the string returned byrepr() using \x, \u, or \U escapes. This generates a stringsimilar to that returned by repr() in Python 2.

Return True if the object argument appears callable,False if not. If this returns True, it is still possible that acall fails, but if it is False, calling object will never succeed.Note that classes are callable (calling a class returns a new instance);instances are callable if their class has a __call__() method.

A class method can be called either on the class (such as C.f()) or on an instance (suchas C().f()). The instance is ignored except for its class. If a classmethod is called for a derived class, the derived class object is passed as theimplied first argument.

Compile the source into a code or AST object. Code objects can be executedby exec() or eval(). source can either be a normal string, abyte string, or an AST object. Refer to the ast module documentationfor information on how to work with AST objects.

The mode argument specifies what kind of code must be compiled; it can be'exec' if source consists of a sequence of statements, 'eval' if itconsists of a single expression, or 'single' if it consists of a singleinteractive statement (in the latter case, expression statements thatevaluate to something other than None will be printed).

Compiler options and future statements are specified by bits which can bebitwise ORed together to specify multiple options. The bitfield required tospecify a given future feature can be found as thecompiler_flag attribute on the_Feature instance in the __future__ module.Compiler flags can be found in astmodule, with PyCF_ prefix.

When compiling a string with multi-line code in 'single' or'eval' mode, input must be terminated by at least one newlinecharacter. This is to facilitate detection of incomplete and completestatements in the code module.

If the argument is a string, it must contain either a real part (in thesame format as for float()) or an imaginary part (in the sameformat but with a 'j' or 'J' suffix), or both real and imaginaryparts (the sign of the imaginary part is mandatory in this case).The string can optionally be surrounded by whitespaces and the roundparentheses '(' and ')', which are ignored.The string must not contain whitespace between '+', '-', the'j' or 'J' suffix, and the decimal number.For example, complex('1+2j') is fine, but complex('1 + 2j') raisesValueError.More precisely, the input must conform to the complexvalueproduction rule in the following grammar, after parentheses and leading andtrailing whitespace characters are removed:

If two arguments are provided or keyword arguments are used, each argumentmay be any numeric type (including complex).If both arguments are real numbers, return a complex number with the realcomponent real and the imaginary component imag.If both arguments are complex numbers, return a complex number with the realcomponent real.real-imag.imag and the imaginary componentreal.imag+imag.real.If one of arguments is a real number, only its real component is used inthe above expressions.

Because dir() is supplied primarily as a convenience for use at aninteractive prompt, it tries to supply an interesting set of names morethan it tries to supply a rigorously or consistently defined set of names,and its detailed behavior may change across releases. For example,metaclass attributes are not in the result list when the argument is aclass.

Take two (non-complex) numbers as arguments and return a pair of numbersconsisting of their quotient and remainder when using integer division. Withmixed operand types, the rules for binary arithmetic operators apply. Forintegers, the result is the same as (a // b, a % b). For floating-pointnumbers the result is (q, a % b), where q is usually math.floor(a /b) but may be 1 less than that. In any case q * b + a % b is veryclose to a, if a % b is non-zero it has the same sign as b, and 0

Return an enumerate object. iterable must be a sequence, aniterator, or some other object which supports iteration.The __next__() method of the iterator returned byenumerate() returns a tuple containing a count (from start whichdefaults to 0) and the values obtained from iterating over iterable.

The expression argument is parsed and evaluated as a Python expression(technically speaking, a condition list) using the globals and localsdictionaries as global and local namespace. If the globals dictionary ispresent and does not contain a value for the key __builtins__, areference to the dictionary of the built-in module builtins isinserted under that key before expression is parsed. That way you cancontrol what builtins are available to the executed code by inserting yourown __builtins__ dictionary into globals before passing it toeval(). If the locals dictionary is omitted it defaults to theglobals dictionary. If both dictionaries are omitted, the expression isexecuted with the globals and locals in the environment whereeval() is called. Note, eval() does not have access to thenested scopes (non-locals) in the enclosingenvironment.

This function can also be used to execute arbitrary code objects (such asthose created by compile()). In this case, pass a code object insteadof a string. If the code object has been compiled with 'exec' as themode argument, eval()'s return value will be None.

In all cases, if the optional parts are omitted, the code is executed in thecurrent scope. If only globals is provided, it must be a dictionary(and not a subclass of dictionary), whichwill be used for both the global and the local variables. If globals andlocals are given, they are used for the global and local variables,respectively. If provided, locals can be any mapping object. Rememberthat at the module level, globals and locals are the same dictionary.

If the globals dictionary does not contain a value for the key__builtins__, a reference to the dictionary of the built-in modulebuiltins is inserted under that key. That way you can control whatbuiltins are available to the executed code by inserting your own__builtins__ dictionary into globals before passing it to exec().

The default locals act as described for function locals() below:modifications to the default locals dictionary should not be attempted.Pass an explicit locals dictionary if you need to see effects of thecode on locals after function exec() returns.

Construct an iterator from those elements of iterable for which functionis true. iterable may be either a sequence, a container whichsupports iteration, or an iterator. If function is None, the identityfunction is assumed, that is, all elements of iterable that are false areremoved.

Note that filter(function, iterable) is equivalent to the generatorexpression (item for item in iterable if function(item)) if function isnot None and (item for item in iterable if item) if function isNone.

If the argument is a string, it should contain a decimal number, optionallypreceded by a sign, and optionally embedded in whitespace. The optionalsign may be '+' or '-'; a '+' sign has no effect on the valueproduced. The argument may also be a string representing a NaN(not-a-number), or positive or negative infinity.More precisely, the input must conform to the floatvalueproduction rule in the following grammar, after leading and trailingwhitespace characters are removed:

Return the hash value of the object (if it has one). Hash values areintegers. They are used to quickly compare dictionary keys during adictionary lookup. Numeric values that compare equal have the same hashvalue (even if they are of different types, as is the case for 1 and 1.0).

Invoke the built-in help system. (This function is intended for interactiveuse.) If no argument is given, the interactive help system starts on theinterpreter console. If the argument is a string, then the string is looked upas the name of a module, function, class, method, keyword, or documentationtopic, and a help page is printed on the console. If the argument is any otherkind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function wheninvoking help(), it means that the parameters prior to the slash arepositional-only. For more info, seethe FAQ entry on positional-only parameters.

If the prompt argument is present, it is written to standard output withouta trailing newline. The function then reads a line from input, converts itto a string (stripping a trailing newline), and returns that. When EOF isread, EOFError is raised. Example:

If the argument is not a number or if base is given, then it must be a string,bytes, or bytearray instance representing an integerin radix base. Optionally, the string can be preceded by + or -(with no space in between), have leading zeros, be surrounded by whitespace,and have single underscores interspersed between digits.

Changed in version 3.4: If base is not an instance of int and the base object has abase.__index__ method, that method is calledto obtain an integer for the base. Previous versions usedbase.__int__ instead of base.__index__.

Changed in version 3.11: int string inputs and string representations can be limited tohelp avoid denial of service attacks. A ValueError is raised whenthe limit is exceeded while converting a string to an int orwhen converting an int into a string would exceed the limit.See the integer string conversion length limitation documentation.

Return True if the object argument is an instance of the classinfoargument, or of a (direct, indirect, or virtual) subclass thereof. If object is notan object of the given type, the function always returns False.If classinfo is a tuple of type objects (or recursively, other suchtuples) or a Union Type of multiple types, return True ifobject is an instance of any of the types.If classinfo is not a type or tuple of types and such tuples,a TypeError exception is raised. TypeError may not beraised for an invalid type if an earlier check succeeds.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages