- Glossary - T
- ********
- text encoding
- A string in Python is a sequence of Unicode code points (in range
- "U+0000"--"U+10FFFF"). To store or transfer a string, it needs to
- be serialized as a sequence of bytes.
- Serializing a string into a sequence of bytes is known as
- "encoding", and recreating the string from the sequence of bytes is
- known as "decoding".
- There are a variety of different text serialization codecs, which
- are collectively referred to as "text encodings".
- text file
- A *file object* able to read and write "str" objects. Often, a text
- file actually accesses a byte-oriented datastream and handles the
- *text encoding* automatically. Examples of text files are files
- opened in text mode ("'r'" or "'w'"), "sys.stdin", "sys.stdout",
- and instances of "io.StringIO".
- See also *binary file* for a file object able to read and write
- *bytes-like objects*.
- triple-quoted string
- A string which is bound by three instances of either a quotation
- mark (") or an apostrophe ('). While they don't provide any
- functionality not available with single-quoted strings, they are
- useful for a number of reasons. They allow you to include
- unescaped single and double quotes within a string and they can
- span multiple lines without the use of the continuation character,
- making them especially useful when writing docstrings.
- type
- The type of a Python object determines what kind of object it is;
- every object has a type. An object's type is accessible as its
- "__class__" attribute or can be retrieved with "type(obj)".
- type alias
- A synonym for a type, created by assigning the type to an
- identifier.
- Type aliases are useful for simplifying *type hints*. For example:
- def remove_gray_shades(
- colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:
- pass
- could be made more readable like this:
- Color = tuple[int, int, int]
- def remove_gray_shades(colors: list[Color]) -> list[Color]:
- pass
- See "typing" and **PEP 484**, which describe this functionality.
- type hint
- An *annotation* that specifies the expected type for a variable, a
- class attribute, or a function parameter or return value.
- Type hints are optional and are not enforced by Python but they are
- useful to static type analysis tools, and aid IDEs with code
- completion and refactoring.
- Type hints of global variables, class attributes, and functions,
- but not local variables, can be accessed using
- "typing.get_type_hints()".
- See "typing" and **PEP 484**, which describe this functionality.
- Beginner Python3: Encoding and Decoding
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license