doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
FTP.cwd(pathname) Set the current directory on the server.
python.library.ftplib#ftplib.FTP.cwd
FTP.delete(filename) Remove the file named filename from the server. If successful, returns the text of the response, otherwise raises error_perm on permission errors or error_reply on other errors.
python.library.ftplib#ftplib.FTP.delete
FTP.dir(argument[, ...]) Produce a directory listing as returned by the LIST command, printing it to standard output. The optional argument is a directory to list (default is the current server directory). Multiple arguments can be used to pass non-standard options to the LIST command. If the last argument is a funct...
python.library.ftplib#ftplib.FTP.dir
FTP.getwelcome() Return the welcome message sent by the server in reply to the initial connection. (This message sometimes contains disclaimers or help information that may be relevant to the user.)
python.library.ftplib#ftplib.FTP.getwelcome
FTP.login(user='anonymous', passwd='', acct='') Log in as the given user. The passwd and acct parameters are optional and default to the empty string. If no user is specified, it defaults to 'anonymous'. If user is 'anonymous', the default passwd is 'anonymous@'. This function should be called only once for each inst...
python.library.ftplib#ftplib.FTP.login
FTP.mkd(pathname) Create a new directory on the server.
python.library.ftplib#ftplib.FTP.mkd
FTP.mlsd(path="", facts=[]) List a directory in a standardized format by using MLSD command (RFC 3659). If path is omitted the current directory is assumed. facts is a list of strings representing the type of information desired (e.g. ["type", "size", "perm"]). Return a generator object yielding a tuple of two elemen...
python.library.ftplib#ftplib.FTP.mlsd
FTP.nlst(argument[, ...]) Return a list of file names as returned by the NLST command. The optional argument is a directory to list (default is the current server directory). Multiple arguments can be used to pass non-standard options to the NLST command. Note If your server supports the command, mlsd() offers a bet...
python.library.ftplib#ftplib.FTP.nlst
FTP.ntransfercmd(cmd, rest=None) Like transfercmd(), but returns a tuple of the data connection and the expected size of the data. If the expected size could not be computed, None will be returned as the expected size. cmd and rest means the same thing as in transfercmd().
python.library.ftplib#ftplib.FTP.ntransfercmd
FTP.pwd() Return the pathname of the current directory on the server.
python.library.ftplib#ftplib.FTP.pwd
FTP.quit() Send a QUIT command to the server and close the connection. This is the “polite” way to close a connection, but it may raise an exception if the server responds with an error to the QUIT command. This implies a call to the close() method which renders the FTP instance useless for subsequent calls (see belo...
python.library.ftplib#ftplib.FTP.quit
FTP.rename(fromname, toname) Rename file fromname on the server to toname.
python.library.ftplib#ftplib.FTP.rename
FTP.retrbinary(cmd, callback, blocksize=8192, rest=None) Retrieve a file in binary transfer mode. cmd should be an appropriate RETR command: 'RETR filename'. The callback function is called for each block of data received, with a single bytes argument giving the data block. The optional blocksize argument specifies t...
python.library.ftplib#ftplib.FTP.retrbinary
FTP.retrlines(cmd, callback=None) Retrieve a file or directory listing in the encoding specified by the encoding parameter at initialization. cmd should be an appropriate RETR command (see retrbinary()) or a command such as LIST or NLST (usually just the string 'LIST'). LIST retrieves a list of files and information ...
python.library.ftplib#ftplib.FTP.retrlines
FTP.rmd(dirname) Remove the directory named dirname on the server.
python.library.ftplib#ftplib.FTP.rmd
FTP.sendcmd(cmd) Send a simple command string to the server and return the response string. Raises an auditing event ftplib.sendcmd with arguments self, cmd.
python.library.ftplib#ftplib.FTP.sendcmd
FTP.set_debuglevel(level) Set the instance’s debugging level. This controls the amount of debugging output printed. The default, 0, produces no debugging output. A value of 1 produces a moderate amount of debugging output, generally a single line per request. A value of 2 or higher produces the maximum amount of debu...
python.library.ftplib#ftplib.FTP.set_debuglevel
FTP.set_pasv(val) Enable “passive” mode if val is true, otherwise disable passive mode. Passive mode is on by default.
python.library.ftplib#ftplib.FTP.set_pasv
FTP.size(filename) Request the size of the file named filename on the server. On success, the size of the file is returned as an integer, otherwise None is returned. Note that the SIZE command is not standardized, but is supported by many common server implementations.
python.library.ftplib#ftplib.FTP.size
FTP.storbinary(cmd, fp, blocksize=8192, callback=None, rest=None) Store a file in binary transfer mode. cmd should be an appropriate STOR command: "STOR filename". fp is a file object (opened in binary mode) which is read until EOF using its read() method in blocks of size blocksize to provide the data to be stored. ...
python.library.ftplib#ftplib.FTP.storbinary
FTP.storlines(cmd, fp, callback=None) Store a file in line mode. cmd should be an appropriate STOR command (see storbinary()). Lines are read until EOF from the file object fp (opened in binary mode) using its readline() method to provide the data to be stored. callback is an optional single parameter callable that i...
python.library.ftplib#ftplib.FTP.storlines
FTP.transfercmd(cmd, rest=None) Initiate a transfer over the data connection. If the transfer is active, send an EPRT or PORT command and the transfer command specified by cmd, and accept the connection. If the server is passive, send an EPSV or PASV command, connect to it, and start the transfer command. Either way,...
python.library.ftplib#ftplib.FTP.transfercmd
FTP.voidcmd(cmd) Send a simple command string to the server and handle the response. Return nothing if a response code corresponding to success (codes in the range 200–299) is received. Raise error_reply otherwise. Raises an auditing event ftplib.sendcmd with arguments self, cmd.
python.library.ftplib#ftplib.FTP.voidcmd
class ftplib.FTP_TLS(host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=None, source_address=None, *, encoding='utf-8') A FTP subclass which adds TLS support to FTP as described in RFC 4217. Connect as usual to port 21 implicitly securing the FTP control connection before authent...
python.library.ftplib#ftplib.FTP_TLS
FTP_TLS.auth() Set up a secure control connection by using TLS or SSL, depending on what is specified in the ssl_version attribute. Changed in version 3.4: The method now supports hostname check with ssl.SSLContext.check_hostname and Server Name Indication (see ssl.HAS_SNI).
python.library.ftplib#ftplib.FTP_TLS.auth
FTP_TLS.ccc() Revert control channel back to plaintext. This can be useful to take advantage of firewalls that know how to handle NAT with non-secure FTP without opening fixed ports. New in version 3.3.
python.library.ftplib#ftplib.FTP_TLS.ccc
FTP_TLS.prot_c() Set up clear text data connection.
python.library.ftplib#ftplib.FTP_TLS.prot_c
FTP_TLS.prot_p() Set up secure data connection.
python.library.ftplib#ftplib.FTP_TLS.prot_p
FTP_TLS.ssl_version The SSL version to use (defaults to ssl.PROTOCOL_SSLv23).
python.library.ftplib#ftplib.FTP_TLS.ssl_version
Built-in Functions The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order. Built-in Functions abs() delattr() hash() memoryview() set() all() dict() help() min() setattr() any() dir() hex() next() slice() ascii() div...
python.library.functions
functools — Higher-order functions and operations on callable objects Source code: Lib/functools.py The functools module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module. The functools module defi...
python.library.functools
@functools.cache(user_function) Simple lightweight unbounded function cache. Sometimes called “memoize”. Returns the same as lru_cache(maxsize=None), creating a thin wrapper around a dictionary lookup for the function arguments. Because it never needs to evict old values, this is smaller and faster than lru_cache() w...
python.library.functools#functools.cache
@functools.cached_property(func) Transform a method of a class into a property whose value is computed once and then cached as a normal attribute for the life of the instance. Similar to property(), with the addition of caching. Useful for expensive computed properties of instances that are otherwise effectively immu...
python.library.functools#functools.cached_property
functools.cmp_to_key(func) Transform an old-style comparison function to a key function. Used with tools that accept key functions (such as sorted(), min(), max(), heapq.nlargest(), heapq.nsmallest(), itertools.groupby()). This function is primarily used as a transition tool for programs being converted from Python 2...
python.library.functools#functools.cmp_to_key
@functools.lru_cache(user_function) @functools.lru_cache(maxsize=128, typed=False) Decorator to wrap a function with a memoizing callable that saves up to the maxsize most recent calls. It can save time when an expensive or I/O bound function is periodically called with the same arguments. Since a dictionary is use...
python.library.functools#functools.lru_cache
functools.partial(func, /, *args, **keywords) Return a new partial object which when called will behave like func called with the positional arguments args and keyword arguments keywords. If more arguments are supplied to the call, they are appended to args. If additional keyword arguments are supplied, they extend a...
python.library.functools#functools.partial
partial.args The leftmost positional arguments that will be prepended to the positional arguments provided to a partial object call.
python.library.functools#functools.partial.args
partial.func A callable object or function. Calls to the partial object will be forwarded to func with new arguments and keywords.
python.library.functools#functools.partial.func
partial.keywords The keyword arguments that will be supplied when the partial object is called.
python.library.functools#functools.partial.keywords
class functools.partialmethod(func, /, *args, **keywords) Return a new partialmethod descriptor which behaves like partial except that it is designed to be used as a method definition rather than being directly callable. func must be a descriptor or a callable (objects which are both, like normal functions, are handl...
python.library.functools#functools.partialmethod
functools.reduce(function, iterable[, initializer]) Apply function of two arguments cumulatively to the items of iterable, from left to right, so as to reduce the iterable to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). The left argument, x, is the accumulated v...
python.library.functools#functools.reduce
@functools.singledispatch Transform a function into a single-dispatch generic function. To define a generic function, decorate it with the @singledispatch decorator. Note that the dispatch happens on the type of the first argument, create your function accordingly: >>> from functools import singledispatch >>> @single...
python.library.functools#functools.singledispatch
class functools.singledispatchmethod(func) Transform a method into a single-dispatch generic function. To define a generic method, decorate it with the @singledispatchmethod decorator. Note that the dispatch happens on the type of the first non-self or non-cls argument, create your function accordingly: class Negator...
python.library.functools#functools.singledispatchmethod
@functools.total_ordering Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. This simplifies the effort involved in specifying all of the possible rich comparison operations: The class must define one of __lt__(), __le__(), __gt__(), or __ge__(). In addition, ...
python.library.functools#functools.total_ordering
functools.update_wrapper(wrapper, wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) Update a wrapper function to look like the wrapped function. The optional arguments are tuples to specify which attributes of the original function are assigned directly to the matching attributes on the wrapper function...
python.library.functools#functools.update_wrapper
@functools.wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) This is a convenience function for invoking update_wrapper() as a function decorator when defining a wrapper function. It is equivalent to partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated). For example: >>> fro...
python.library.functools#functools.wraps
Futures Source code: Lib/asyncio/futures.py, Lib/asyncio/base_futures.py Future objects are used to bridge low-level callback-based code with high-level async/await code. Future Functions asyncio.isfuture(obj) Return True if obj is either of: an instance of asyncio.Future, an instance of asyncio.Task, a Future-lik...
python.library.asyncio-future
exception FutureWarning Base class for warnings about deprecated features when those warnings are intended for end users of applications that are written in Python.
python.library.exceptions#FutureWarning
gc — Garbage Collector interface This module provides an interface to the optional garbage collector. It provides the ability to disable the collector, tune the collection frequency, and set debugging options. It also provides access to unreachable objects that the collector found but cannot free. Since the collector s...
python.library.gc
gc.callbacks A list of callbacks that will be invoked by the garbage collector before and after collection. The callbacks will be called with two arguments, phase and info. phase can be one of two values: “start”: The garbage collection is about to start. “stop”: The garbage collection has finished. info is a dict pr...
python.library.gc#gc.callbacks
gc.collect(generation=2) With no arguments, run a full collection. The optional argument generation may be an integer specifying which generation to collect (from 0 to 2). A ValueError is raised if the generation number is invalid. The number of unreachable objects found is returned. The free lists maintained for a n...
python.library.gc#gc.collect
gc.DEBUG_COLLECTABLE Print information on collectable objects found.
python.library.gc#gc.DEBUG_COLLECTABLE
gc.DEBUG_LEAK The debugging flags necessary for the collector to print information about a leaking program (equal to DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | DEBUG_SAVEALL).
python.library.gc#gc.DEBUG_LEAK
gc.DEBUG_SAVEALL When set, all unreachable objects found will be appended to garbage rather than being freed. This can be useful for debugging a leaking program.
python.library.gc#gc.DEBUG_SAVEALL
gc.DEBUG_STATS Print statistics during collection. This information can be useful when tuning the collection frequency.
python.library.gc#gc.DEBUG_STATS
gc.DEBUG_UNCOLLECTABLE Print information of uncollectable objects found (objects which are not reachable but cannot be freed by the collector). These objects will be added to the garbage list. Changed in version 3.2: Also print the contents of the garbage list at interpreter shutdown, if it isn’t empty.
python.library.gc#gc.DEBUG_UNCOLLECTABLE
gc.disable() Disable automatic garbage collection.
python.library.gc#gc.disable
gc.enable() Enable automatic garbage collection.
python.library.gc#gc.enable
gc.freeze() Freeze all the objects tracked by gc - move them to a permanent generation and ignore all the future collections. This can be used before a POSIX fork() call to make the gc copy-on-write friendly or to speed up collection. Also collection before a POSIX fork() call may free pages for future allocation whi...
python.library.gc#gc.freeze
gc.garbage A list of objects which the collector found to be unreachable but could not be freed (uncollectable objects). Starting with Python 3.4, this list should be empty most of the time, except when using instances of C extension types with a non-NULL tp_del slot. If DEBUG_SAVEALL is set, then all unreachable obj...
python.library.gc#gc.garbage
gc.get_count() Return the current collection counts as a tuple of (count0, count1, count2).
python.library.gc#gc.get_count
gc.get_debug() Return the debugging flags currently set.
python.library.gc#gc.get_debug
gc.get_freeze_count() Return the number of objects in the permanent generation. New in version 3.7.
python.library.gc#gc.get_freeze_count
gc.get_objects(generation=None) Returns a list of all objects tracked by the collector, excluding the list returned. If generation is not None, return only the objects tracked by the collector that are in that generation. Changed in version 3.8: New generation parameter. Raises an auditing event gc.get_objects with...
python.library.gc#gc.get_objects
gc.get_referents(*objs) Return a list of objects directly referred to by any of the arguments. The referents returned are those objects visited by the arguments’ C-level tp_traverse methods (if any), and may not be all objects actually directly reachable. tp_traverse methods are supported only by objects that support...
python.library.gc#gc.get_referents
gc.get_referrers(*objs) Return the list of objects that directly refer to any of objs. This function will only locate those containers which support garbage collection; extension types which do refer to other objects but do not support garbage collection will not be found. Note that objects which have already been de...
python.library.gc#gc.get_referrers
gc.get_stats() Return a list of three per-generation dictionaries containing collection statistics since interpreter start. The number of keys may change in the future, but currently each dictionary will contain the following items: collections is the number of times this generation was collected; collected is the...
python.library.gc#gc.get_stats
gc.get_threshold() Return the current collection thresholds as a tuple of (threshold0, threshold1, threshold2).
python.library.gc#gc.get_threshold
gc.isenabled() Return True if automatic collection is enabled.
python.library.gc#gc.isenabled
gc.is_finalized(obj) Returns True if the given object has been finalized by the garbage collector, False otherwise. >>> x = None >>> class Lazarus: ... def __del__(self): ... global x ... x = self ... >>> lazarus = Lazarus() >>> gc.is_finalized(lazarus) False >>> del lazarus >>> gc.is_finalized(x)...
python.library.gc#gc.is_finalized
gc.is_tracked(obj) Returns True if the object is currently tracked by the garbage collector, False otherwise. As a general rule, instances of atomic types aren’t tracked and instances of non-atomic types (containers, user-defined objects…) are. However, some type-specific optimizations can be present in order to supp...
python.library.gc#gc.is_tracked
gc.set_debug(flags) Set the garbage collection debugging flags. Debugging information will be written to sys.stderr. See below for a list of debugging flags which can be combined using bit operations to control debugging.
python.library.gc#gc.set_debug
gc.set_threshold(threshold0[, threshold1[, threshold2]]) Set the garbage collection thresholds (the collection frequency). Setting threshold0 to zero disables collection. The GC classifies objects into three generations depending on how many collection sweeps they have survived. New objects are placed in the youngest...
python.library.gc#gc.set_threshold
gc.unfreeze() Unfreeze the objects in the permanent generation, put them back into the oldest generation. New in version 3.7.
python.library.gc#gc.unfreeze
exception GeneratorExit Raised when a generator or coroutine is closed; see generator.close() and coroutine.close(). It directly inherits from BaseException instead of Exception since it is technically not an error.
python.library.exceptions#GeneratorExit
genericalias.__args__ This attribute is a tuple (possibly of length 1) of generic types passed to the original __class_getitem__() of the generic container: >>> dict[str, list[int]].__args__ (<class 'str'>, list[int])
python.library.stdtypes#genericalias.__args__
genericalias.__origin__ This attribute points at the non-parameterized generic class: >>> list[int].__origin__ <class 'list'>
python.library.stdtypes#genericalias.__origin__
genericalias.__parameters__ This attribute is a lazily computed tuple (possibly empty) of unique type variables found in __args__: >>> from typing import TypeVar >>> T = TypeVar('T') >>> list[T].__parameters__ (~T,)
python.library.stdtypes#genericalias.__parameters__
getattr(object, name[, default]) Return the value of the named attribute of object. name must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. If the named attribute does not exist, default...
python.library.functions#getattr
getopt — C-style parser for command line options Source code: Lib/getopt.py Note The getopt module is a parser for command line options whose API is designed to be familiar to users of the C getopt() function. Users who are unfamiliar with the C getopt() function or who would like to write less code and get better hel...
python.library.getopt
exception getopt.error Alias for GetoptError; for backward compatibility.
python.library.getopt#getopt.error
getopt.getopt(args, shortopts, longopts=[]) Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means sys.argv[1:]. shortopts is the string of option letters that the script wants to recognize, with options that ...
python.library.getopt#getopt.getopt
exception getopt.GetoptError This is raised when an unrecognized option is found in the argument list or when an option requiring an argument is given none. The argument to the exception is a string indicating the cause of the error. For long options, an argument given to an option which does not require one will als...
python.library.getopt#getopt.GetoptError
getopt.gnu_getopt(args, shortopts, longopts=[]) This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is encountered. If the first cha...
python.library.getopt#getopt.gnu_getopt
getpass — Portable password input Source code: Lib/getpass.py The getpass module provides two functions: getpass.getpass(prompt='Password: ', stream=None) Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to 'Password: '. On Unix, the prompt is written to t...
python.library.getpass
getpass.getpass(prompt='Password: ', stream=None) Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to 'Password: '. On Unix, the prompt is written to the file-like object stream using the replace error handler if needed. stream defaults to the controlling te...
python.library.getpass#getpass.getpass
exception getpass.GetPassWarning A UserWarning subclass issued when password input may be echoed.
python.library.getpass#getpass.GetPassWarning
getpass.getuser() Return the “login name” of the user. This function checks the environment variables LOGNAME, USER, LNAME and USERNAME, in order, and returns the value of the first one which is set to a non-empty string. If none are set, the login name from the password database is returned on systems which support ...
python.library.getpass#getpass.getuser
gettext — Multilingual internationalization services Source code: Lib/gettext.py The gettext module provides internationalization (I18N) and localization (L10N) services for your Python modules and applications. It supports both the GNU gettext message catalog API and a higher level, class-based API that may be more ap...
python.library.gettext
gettext.bindtextdomain(domain, localedir=None) Bind the domain to the locale directory localedir. More concretely, gettext will look for binary .mo files for the given domain using the path (on Unix): localedir/language/LC_MESSAGES/domain.mo, where language is searched for in the environment variables LANGUAGE, LC_AL...
python.library.gettext#gettext.bindtextdomain
gettext.bind_textdomain_codeset(domain, codeset=None) Bind the domain to codeset, changing the encoding of byte strings returned by the lgettext(), ldgettext(), lngettext() and ldngettext() functions. If codeset is omitted, then the current binding is returned. Deprecated since version 3.8, will be removed in versio...
python.library.gettext#gettext.bind_textdomain_codeset
gettext.dgettext(domain, message) Like gettext(), but look the message up in the specified domain.
python.library.gettext#gettext.dgettext
gettext.dngettext(domain, singular, plural, n) Like ngettext(), but look the message up in the specified domain.
python.library.gettext#gettext.dngettext
gettext.dnpgettext(domain, context, singular, plural, n) Similar to the corresponding functions without the p in the prefix (that is, gettext(), dgettext(), ngettext(), dngettext()), but the translation is restricted to the given message context. New in version 3.8.
python.library.gettext#gettext.dnpgettext
gettext.dpgettext(domain, context, message)
python.library.gettext#gettext.dpgettext
gettext.find(domain, localedir=None, languages=None, all=False) This function implements the standard .mo file search algorithm. It takes a domain, identical to what textdomain() takes. Optional localedir is as in bindtextdomain(). Optional languages is a list of strings, where each string is a language code. If loca...
python.library.gettext#gettext.find
gettext.gettext(message) Return the localized translation of message, based on the current global domain, language, and locale directory. This function is usually aliased as _() in the local namespace (see examples below).
python.library.gettext#gettext.gettext
class gettext.GNUTranslations The following methods are overridden from the base class implementation: gettext(message) Look up the message id in the catalog and return the corresponding message string, as a Unicode string. If there is no entry in the catalog for the message id, and a fallback has been set, the l...
python.library.gettext#gettext.GNUTranslations
gettext(message) Look up the message id in the catalog and return the corresponding message string, as a Unicode string. If there is no entry in the catalog for the message id, and a fallback has been set, the look up is forwarded to the fallback’s gettext() method. Otherwise, the message id is returned.
python.library.gettext#gettext.GNUTranslations.gettext
lgettext(message)
python.library.gettext#gettext.GNUTranslations.lgettext