doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
OpenerDirector.error(proto, *args) Handle an error of the given protocol. This will call the registered error handlers for the given protocol with the given arguments (which are protocol specific). The HTTP protocol is a special case which uses the HTTP response code to determine the specific error handler; refer to ...
python.library.urllib.request#urllib.request.OpenerDirector.error
OpenerDirector.open(url, data=None[, timeout]) Open the given url (which can be a request object or a string), optionally passing the given data. Arguments, return values and exceptions raised are the same as those of urlopen() (which simply calls the open() method on the currently installed global OpenerDirector). T...
python.library.urllib.request#urllib.request.OpenerDirector.open
urllib.request.pathname2url(path) Convert the pathname path from the local syntax for a path to the form used in the path component of a URL. This does not produce a complete URL. The return value will already be quoted using the quote() function.
python.library.urllib.request#urllib.request.pathname2url
class urllib.request.ProxyBasicAuthHandler(password_mgr=None) Handle authentication with the proxy. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported.
python.library.urllib.request#urllib.request.ProxyBasicAuthHandler
ProxyBasicAuthHandler.http_error_407(req, fp, code, msg, hdrs) Retry the request with authentication information, if available.
python.library.urllib.request#urllib.request.ProxyBasicAuthHandler.http_error_407
class urllib.request.ProxyDigestAuthHandler(password_mgr=None) Handle authentication with the proxy. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported.
python.library.urllib.request#urllib.request.ProxyDigestAuthHandler
ProxyDigestAuthHandler.http_error_407(req, fp, code, msg, hdrs) Retry the request with authentication information, if available.
python.library.urllib.request#urllib.request.ProxyDigestAuthHandler.http_error_407
class urllib.request.ProxyHandler(proxies=None) Cause requests to go through a proxy. If proxies is given, it must be a dictionary mapping protocol names to URLs of proxies. The default is to read the list of proxies from the environment variables <protocol>_proxy. If no proxy environment variables are set, then in a...
python.library.urllib.request#urllib.request.ProxyHandler
class urllib.request.Request(url, data=None, headers={}, origin_req_host=None, unverifiable=False, method=None) This class is an abstraction of a URL request. url should be a string containing a valid URL. data must be an object specifying additional data to send to the server, or None if no such data is needed. Curr...
python.library.urllib.request#urllib.request.Request
Request.add_header(key, val) Add another header to the request. Headers are currently ignored by all handlers except HTTP handlers, where they are added to the list of headers sent to the server. Note that there cannot be more than one header with the same name, and later calls will overwrite previous calls in case t...
python.library.urllib.request#urllib.request.Request.add_header
Request.add_unredirected_header(key, header) Add a header that will not be added to a redirected request.
python.library.urllib.request#urllib.request.Request.add_unredirected_header
Request.data The entity body for the request, or None if not specified. Changed in version 3.4: Changing value of Request.data now deletes “Content-Length” header if it was previously set or calculated.
python.library.urllib.request#urllib.request.Request.data
Request.full_url The original URL passed to the constructor. Changed in version 3.4. Request.full_url is a property with setter, getter and a deleter. Getting full_url returns the original request URL with the fragment, if it was present.
python.library.urllib.request#urllib.request.Request.full_url
Request.get_full_url() Return the URL given in the constructor. Changed in version 3.4. Returns Request.full_url
python.library.urllib.request#urllib.request.Request.get_full_url
Request.get_header(header_name, default=None) Return the value of the given header. If the header is not present, return the default value.
python.library.urllib.request#urllib.request.Request.get_header
Request.get_method() Return a string indicating the HTTP request method. If Request.method is not None, return its value, otherwise return 'GET' if Request.data is None, or 'POST' if it’s not. This is only meaningful for HTTP requests. Changed in version 3.3: get_method now looks at the value of Request.method.
python.library.urllib.request#urllib.request.Request.get_method
Request.has_header(header) Return whether the instance has the named header (checks both regular and unredirected).
python.library.urllib.request#urllib.request.Request.has_header
Request.header_items() Return a list of tuples (header_name, header_value) of the Request headers.
python.library.urllib.request#urllib.request.Request.header_items
Request.host The URI authority, typically a host, but may also contain a port separated by a colon.
python.library.urllib.request#urllib.request.Request.host
Request.method The HTTP request method to use. By default its value is None, which means that get_method() will do its normal computation of the method to be used. Its value can be set (thus overriding the default computation in get_method()) either by providing a default value by setting it at the class level in a R...
python.library.urllib.request#urllib.request.Request.method
Request.origin_req_host The original host for the request, without port.
python.library.urllib.request#urllib.request.Request.origin_req_host
Request.remove_header(header) Remove named header from the request instance (both from regular and unredirected headers). New in version 3.4.
python.library.urllib.request#urllib.request.Request.remove_header
Request.selector The URI path. If the Request uses a proxy, then selector will be the full URL that is passed to the proxy.
python.library.urllib.request#urllib.request.Request.selector
Request.set_proxy(host, type) Prepare the request by connecting to a proxy server. The host and type will replace those of the instance, and the instance’s selector will be the original URL given in the constructor.
python.library.urllib.request#urllib.request.Request.set_proxy
Request.type The URI scheme.
python.library.urllib.request#urllib.request.Request.type
Request.unverifiable boolean, indicates whether the request is unverifiable as defined by RFC 2965.
python.library.urllib.request#urllib.request.Request.unverifiable
class urllib.request.UnknownHandler A catch-all class to handle unknown URLs.
python.library.urllib.request#urllib.request.UnknownHandler
UnknownHandler.unknown_open() Raise a URLError exception.
python.library.urllib.request#urllib.request.UnknownHandler.unknown_open
urllib.request.url2pathname(path) Convert the path component path from a percent-encoded URL to the local syntax for a path. This does not accept a complete URL. This function uses unquote() to decode path.
python.library.urllib.request#urllib.request.url2pathname
urllib.request.urlcleanup() Cleans up temporary files that may have been left behind by previous calls to urlretrieve().
python.library.urllib.request#urllib.request.urlcleanup
urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None) Open the URL url, which can be either a string or a Request object. data must be an object specifying additional data to be sent to the server, or None if no such data is needed. See Request for details. urll...
python.library.urllib.request#urllib.request.urlopen
class urllib.request.URLopener(proxies=None, **x509) Deprecated since version 3.3. Base class for opening and reading URLs. Unless you need to support opening objects using schemes other than http:, ftp:, or file:, you probably want to use FancyURLopener. By default, the URLopener class sends a User-Agent header of...
python.library.urllib.request#urllib.request.URLopener
open(fullurl, data=None) Open fullurl using the appropriate protocol. This method sets up cache and proxy information, then calls the appropriate open method with its input arguments. If the scheme is not recognized, open_unknown() is called. The data argument has the same meaning as the data argument of urlopen(). T...
python.library.urllib.request#urllib.request.URLopener.open
open_unknown(fullurl, data=None) Overridable interface to open unknown URL types.
python.library.urllib.request#urllib.request.URLopener.open_unknown
retrieve(url, filename=None, reporthook=None, data=None) Retrieves the contents of url and places it in filename. The return value is a tuple consisting of a local filename and either an email.message.Message object containing the response headers (for remote URLs) or None (for local URLs). The caller must then open ...
python.library.urllib.request#urllib.request.URLopener.retrieve
version Variable that specifies the user agent of the opener object. To get urllib to tell servers that it is a particular user agent, set this in a subclass as a class variable or in the constructor before calling the base constructor.
python.library.urllib.request#urllib.request.URLopener.version
urllib.request.urlretrieve(url, filename=None, reporthook=None, data=None) Copy a network object denoted by a URL to a local file. If the URL points to a local file, the object will not be copied unless filename is supplied. Return a tuple (filename, headers) where filename is the local file name under which the obje...
python.library.urllib.request#urllib.request.urlretrieve
class urllib.response.addinfourl url URL of the resource retrieved, commonly used to determine if a redirect was followed. headers Returns the headers of the response in the form of an EmailMessage instance. status New in version 3.9. Status code returned by server. geturl() Deprecated since ...
python.library.urllib.request#urllib.response.addinfourl
code Deprecated since version 3.9: Deprecated in favor of status.
python.library.urllib.request#urllib.response.addinfourl.code
getstatus() Deprecated since version 3.9: Deprecated in favor of status.
python.library.urllib.request#urllib.response.addinfourl.getstatus
geturl() Deprecated since version 3.9: Deprecated in favor of url.
python.library.urllib.request#urllib.response.addinfourl.geturl
headers Returns the headers of the response in the form of an EmailMessage instance.
python.library.urllib.request#urllib.response.addinfourl.headers
info() Deprecated since version 3.9: Deprecated in favor of headers.
python.library.urllib.request#urllib.response.addinfourl.info
status New in version 3.9. Status code returned by server.
python.library.urllib.request#urllib.response.addinfourl.status
url URL of the resource retrieved, commonly used to determine if a redirect was followed.
python.library.urllib.request#urllib.response.addinfourl.url
urllib.robotparser — Parser for robots.txt Source code: Lib/urllib/robotparser.py This module provides a single class, RobotFileParser, which answers questions about whether or not a particular user agent can fetch a URL on the Web site that published the robots.txt file. For more details on the structure of robots.txt...
python.library.urllib.robotparser
class urllib.robotparser.RobotFileParser(url='') This class provides methods to read, parse and answer questions about the robots.txt file at url. set_url(url) Sets the URL referring to a robots.txt file. read() Reads the robots.txt URL and feeds it to the parser. parse(lines) Parses the lines argumen...
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser
can_fetch(useragent, url) Returns True if the useragent is allowed to fetch the url according to the rules contained in the parsed robots.txt file.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.can_fetch
crawl_delay(useragent) Returns the value of the Crawl-delay parameter from robots.txt for the useragent in question. If there is no such parameter or it doesn’t apply to the useragent specified or the robots.txt entry for this parameter has invalid syntax, return None. New in version 3.6.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.crawl_delay
modified() Sets the time the robots.txt file was last fetched to the current time.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.modified
mtime() Returns the time the robots.txt file was last fetched. This is useful for long-running web spiders that need to check for new robots.txt files periodically.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.mtime
parse(lines) Parses the lines argument.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.parse
read() Reads the robots.txt URL and feeds it to the parser.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.read
request_rate(useragent) Returns the contents of the Request-rate parameter from robots.txt as a named tuple RequestRate(requests, seconds). If there is no such parameter or it doesn’t apply to the useragent specified or the robots.txt entry for this parameter has invalid syntax, return None. New in version 3.6.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.request_rate
set_url(url) Sets the URL referring to a robots.txt file.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.set_url
site_maps() Returns the contents of the Sitemap parameter from robots.txt in the form of a list(). If there is no such parameter or the robots.txt entry for this parameter has invalid syntax, return None. New in version 3.8.
python.library.urllib.robotparser#urllib.robotparser.RobotFileParser.site_maps
exception UserWarning Base class for warnings generated by user code.
python.library.exceptions#UserWarning
uu — Encode and decode uuencode files Source code: Lib/uu.py This module encodes and decodes files in uuencode format, allowing arbitrary binary data to be transferred over ASCII-only connections. Wherever a file argument is expected, the methods accept a file-like object. For backwards compatibility, a string containi...
python.library.uu
uu.decode(in_file, out_file=None, mode=None, quiet=False) This call decodes uuencoded file in_file placing the result on file out_file. If out_file is a pathname, mode is used to set the permission bits if the file must be created. Defaults for out_file and mode are taken from the uuencode header. However, if the fil...
python.library.uu#uu.decode
uu.encode(in_file, out_file, name=None, mode=None, *, backtick=False) Uuencode file in_file into file out_file. The uuencoded file will have the header specifying name and mode as the defaults for the results of decoding the file. The default defaults are taken from in_file, or '-' and 0o666 respectively. If backtick...
python.library.uu#uu.encode
exception uu.Error Subclass of Exception, this can be raised by uu.decode() under various situations, such as described above, but also including a badly formatted header, or truncated input file.
python.library.uu#uu.Error
uuid — UUID objects according to RFC 4122 Source code: Lib/uuid.py This module provides immutable UUID objects (the UUID class) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122. If all you want is a unique ID, you should probably call uuid1() or u...
python.library.uuid
uuid.getnode() Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with the multicast bit (least significant bit of the first octet) set to 1 ...
python.library.uuid#uuid.getnode
uuid.NAMESPACE_DNS When this namespace is specified, the name string is a fully-qualified domain name.
python.library.uuid#uuid.NAMESPACE_DNS
uuid.NAMESPACE_OID When this namespace is specified, the name string is an ISO OID.
python.library.uuid#uuid.NAMESPACE_OID
uuid.NAMESPACE_URL When this namespace is specified, the name string is a URL.
python.library.uuid#uuid.NAMESPACE_URL
uuid.NAMESPACE_X500 When this namespace is specified, the name string is an X.500 DN in DER or a text output format.
python.library.uuid#uuid.NAMESPACE_X500
uuid.RESERVED_FUTURE Reserved for future definition.
python.library.uuid#uuid.RESERVED_FUTURE
uuid.RESERVED_MICROSOFT Reserved for Microsoft compatibility.
python.library.uuid#uuid.RESERVED_MICROSOFT
uuid.RESERVED_NCS Reserved for NCS compatibility.
python.library.uuid#uuid.RESERVED_NCS
uuid.RFC_4122 Specifies the UUID layout given in RFC 4122.
python.library.uuid#uuid.RFC_4122
class uuid.SafeUUID New in version 3.7. safe The UUID was generated by the platform in a multiprocessing-safe way. unsafe The UUID was not generated in a multiprocessing-safe way. unknown The platform does not provide information on whether the UUID was generated safely or not.
python.library.uuid#uuid.SafeUUID
safe The UUID was generated by the platform in a multiprocessing-safe way.
python.library.uuid#uuid.SafeUUID.safe
unknown The platform does not provide information on whether the UUID was generated safely or not.
python.library.uuid#uuid.SafeUUID.unknown
unsafe The UUID was not generated in a multiprocessing-safe way.
python.library.uuid#uuid.SafeUUID.unsafe
class uuid.UUID(hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=SafeUUID.unknown) Create a UUID from either a string of 32 hexadecimal digits, a string of 16 bytes in big-endian order as the bytes argument, a string of 16 bytes in little-endian order as the bytes_le argument, a tu...
python.library.uuid#uuid.UUID
UUID.bytes The UUID as a 16-byte string (containing the six integer fields in big-endian byte order).
python.library.uuid#uuid.UUID.bytes
UUID.bytes_le The UUID as a 16-byte string (with time_low, time_mid, and time_hi_version in little-endian byte order).
python.library.uuid#uuid.UUID.bytes_le
UUID.fields A tuple of the six integer fields of the UUID, which are also available as six individual attributes and two derived attributes: Field Meaning time_low the first 32 bits of the UUID time_mid the next 16 bits of the UUID time_hi_version the next 16 bits of the UUID clock_seq_hi_variant the next...
python.library.uuid#uuid.UUID.fields
UUID.hex The UUID as a 32-character hexadecimal string.
python.library.uuid#uuid.UUID.hex
UUID.int The UUID as a 128-bit integer.
python.library.uuid#uuid.UUID.int
UUID.is_safe An enumeration of SafeUUID which indicates whether the platform generated the UUID in a multiprocessing-safe way. New in version 3.7.
python.library.uuid#uuid.UUID.is_safe
UUID.urn The UUID as a URN as specified in RFC 4122.
python.library.uuid#uuid.UUID.urn
UUID.variant The UUID variant, which determines the internal layout of the UUID. This will be one of the constants RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE.
python.library.uuid#uuid.UUID.variant
UUID.version The UUID version number (1 through 5, meaningful only when the variant is RFC_4122).
python.library.uuid#uuid.UUID.version
uuid.uuid1(node=None, clock_seq=None) Generate a UUID from a host ID, sequence number, and the current time. If node is not given, getnode() is used to obtain the hardware address. If clock_seq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen.
python.library.uuid#uuid.uuid1
uuid.uuid3(namespace, name) Generate a UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name (which is a string).
python.library.uuid#uuid.uuid3
uuid.uuid4() Generate a random UUID.
python.library.uuid#uuid.uuid4
uuid.uuid5(namespace, name) Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a UUID) and a name (which is a string).
python.library.uuid#uuid.uuid5
exception ValueError Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.
python.library.exceptions#ValueError
vars([object]) Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute. Objects such as modules and instances have an updateable __dict__ attribute; however, other objects may have write restrictions on their __dict__ attributes (for example, classes use a types.Mapp...
python.library.functions#vars
venv — Creation of virtual environments New in version 3.3. Source code: Lib/venv/ The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the v...
python.library.venv
venv.create(env_dir, system_site_packages=False, clear=False, symlinks=False, with_pip=False, prompt=None) Create an EnvBuilder with the given keyword arguments, and call its create() method with the env_dir argument. New in version 3.3. Changed in version 3.4: Added the with_pip parameter Changed in version 3.6...
python.library.venv#venv.create
class venv.EnvBuilder(system_site_packages=False, clear=False, symlinks=False, upgrade=False, with_pip=False, prompt=None, upgrade_deps=False) The EnvBuilder class accepts the following keyword arguments on instantiation: system_site_packages – a Boolean value indicating that the system Python site-packages should ...
python.library.venv#venv.EnvBuilder
create(env_dir) Create a virtual environment by specifying the target directory (absolute or relative to the current directory) which is to contain the virtual environment. The create method will either create the environment in the specified directory, or raise an appropriate exception. The create method of the EnvB...
python.library.venv#venv.EnvBuilder.create
create_configuration(context) Creates the pyvenv.cfg configuration file in the environment.
python.library.venv#venv.EnvBuilder.create_configuration
ensure_directories(env_dir) Creates the environment directory and all necessary directories, and returns a context object. This is just a holder for attributes (such as paths), for use by the other methods. The directories are allowed to exist already, as long as either clear or upgrade were specified to allow operat...
python.library.venv#venv.EnvBuilder.ensure_directories
install_scripts(context, path) path is the path to a directory that should contain subdirectories “common”, “posix”, “nt”, each containing scripts destined for the bin directory in the environment. The contents of “common” and the directory corresponding to os.name are copied after some text replacement of placeholde...
python.library.venv#venv.EnvBuilder.install_scripts
post_setup(context) A placeholder method which can be overridden in third party implementations to pre-install packages in the virtual environment or perform other post-creation steps.
python.library.venv#venv.EnvBuilder.post_setup
setup_python(context) Creates a copy or symlink to the Python executable in the environment. On POSIX systems, if a specific executable python3.x was used, symlinks to python and python3 will be created pointing to that executable, unless files with those names already exist.
python.library.venv#venv.EnvBuilder.setup_python