- What is a callable object? We can say that it is anObject which returns True when its arguments appear callable. If its arguments are not callable the object returns False.
Returns Call Might TRUE Might Fail Might Pass FALSE Will Fail always
- Classes are always callable (calling a class returns a new instance);
- Instances are callable only if their class has a __call__()method.
- Return the string representing a character whose Unicode code point is the integer i. For example, chr(97) returns the string 'a', while chr(957)returns the string 'ν'. This is the inverse of ord().
- The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in base 16). ValueError will be raised if i is outside that range.
- Returns a class method for a function.A class method receives the class as first argument. How to declare a class method?
class C: @classmethod def f(cls, arg1, arg2, ...): ...It can be called either on : 1. the class (as C.f()) or 2. an instance (as C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.Class methods are different than C++ or Java static methods.
- Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte string, or an AST object. Refer to the ast module documentation for information on how to work with AST objects.The filename argument should give the file from which the code was read; pass some recognizable value if it wasn’t read from a file ('
'is commonly used).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 it consists of a single expression, or 'single' if it consists of a single interactive statement (in the latter case, expression statements that evaluate to something other than None will be printed).If neither is present (or both are zero) the code is compiled with those future statements that are in effect in the code that is calling compile(). If the flags argument is given and dont_inherit is not (or is zero) then the future statements specified by the flags argument are used in addition to those that would be used anyway. If dont_inherit is a non-zero integer then the flags argument is it – the future statements in effect around the call to compile are ignored.Future statements are specified by bits which can be bitwise ORed together to specify multiple statements. The bitfield required to specify a given feature can be found as the compiler_flag attribute on the _Feature instance in the __future__ module.The argument optimize specifies the optimization level of the compiler; the default value of -1 selects the optimization level of the interpreter as given by -O options. Explicit levels are 0 (no optimization; __debug__ is true), 1 (asserts are removed, __debug__ is false) or 2 (docstrings are removed too).This function raises SyntaxError if the compiled source is invalid, and TypeError if the source contains null bytes.
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
- Return a complex number with the value real + imag*1j or convert a string or number to a complex number. If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.