logging.FileHandler

class logging.FileHandler(filename, mode='a', encoding=None, delay=False) Returns a new instance of the FileHandler class. The specified file is opened and used as the stream for logging. If mode is not specified, 'a' is used. If encoding is not None, it is used to open the file with that encoding. If delay is true, then file opening is deferred until the first call to emit(). By default, the file grows indefinitely. close() Closes the file. emit(record) Outputs the record to the fi

os.truncate()

os.truncate(path, length) Truncate the file corresponding to path, so that it is at most length bytes in size. This function can support specifying a file descriptor. Availability: Unix, Windows. New in version 3.3. Changed in version 3.5: Added support for Windows

sqlite3.Connection.row_factory

row_factory You can change this attribute to a callable that accepts the cursor and the original row as a tuple and will return the real result row. This way, you can implement more advanced ways of returning results, such as returning an object that can also access columns by name. Example: import sqlite3 def dict_factory(cursor, row): d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d con = sqlite3.connect(":memory:") con.row_factory =

shutil.get_terminal_size()

shutil.get_terminal_size(fallback=(columns, lines)) Get the size of the terminal window. For each of the two dimensions, the environment variable, COLUMNS and LINES respectively, is checked. If the variable is defined and the value is a positive integer, it is used. When COLUMNS or LINES is not defined, which is the common case, the terminal connected to sys.__stdout__ is queried by invoking os.get_terminal_size(). If the terminal size cannot be successfully queried, either because the syste

multiprocessing.managers.BaseProxy

class multiprocessing.managers.BaseProxy Proxy objects are instances of subclasses of BaseProxy. _callmethod(methodname[, args[, kwds]]) Call and return the result of a method of the proxy’s referent. If proxy is a proxy whose referent is obj then the expression proxy._callmethod(methodname, args, kwds) will evaluate the expression getattr(obj, methodname)(*args, **kwds) in the manager’s process. The returned value will be a copy of the result of the call or a proxy to a new shared obje

msvcrt.putch()

msvcrt.putch(char) Print the byte string char to the console without buffering.

asyncio.BaseSubprocessTransport.get_returncode()

get_returncode() Return the subprocess returncode as an integer or None if it hasn’t returned, similarly to the subprocess.Popen.returncode attribute.

bdb.Bdb.trace_dispatch()

trace_dispatch(frame, event, arg) This function is installed as the trace function of debugged frames. Its return value is the new trace function (in most cases, that is, itself). The default implementation decides how to dispatch a frame, depending on the type of event (passed as a string) that is about to be executed. event can be one of the following: "line": A new line of code is going to be executed. "call": A function is about to be called, or another code block entered. "return": A

tracemalloc.Traceback.format()

format(limit=None) Format the traceback as a list of lines with newlines. Use the linecache module to retrieve lines from the source code. If limit is set, only format the limit most recent frames. Similar to the traceback.format_tb() function, except that format() does not include newlines. Example: print("Traceback (most recent call first):") for line in traceback: print(line) Output: Traceback (most recent call first): File "test.py", line 9 obj = Object() File "test.py", lin

timeit.Timer.repeat()

repeat(repeat=3, number=1000000) Call timeit() a few times. This is a convenience function that calls the timeit() repeatedly, returning a list of results. The first argument specifies how many times to call timeit(). The second argument specifies the number argument for timeit(). Note It’s tempting to calculate mean and standard deviation from the result vector and report these. However, this is not very useful. In a typical case, the lowest value gives a lower bound for how fast your mach