sample_id,family_id,query,positives,hard_negatives,answerability,source_refs dp-rt-click-8.5-documentation.md-head0,dp-Click-documentation.md,Click 8.5.0 documentation: Escaping Click's Wrapping,"[""## Showing Defaults\n\nTo control the appearance of defaults pass `show_default`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=False, help='number of dots')\n def dots(n):\n click.echo('.' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\nFor single option boolean flags, the default remains hidden if the default value is False, even if show default is set to true.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=True)\n @click.option(\""--gr\"", is_flag=True, show_default=True, default=False, help=\""Greet the world.\"")\n @click.option(\""--br\"", is_flag=True, show_default=True, default=True, help=\""Add a thematic break\"")\n def dots(n, gr, br):\n if gr:\n click.echo('Hello world!')\n click.echo('.' * n)\n if br:\n click.echo('-' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\n## Showing Environment Variables\n\nTo control the appearance of environment variables pass `show_envvar`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--username', envvar='USERNAME', show_envvar=True)\n def greet(username):\n click.echo(f'Hello {username}!')\n\n.. click:run::\n invoke(greet, args=['--help'])\n```\n\n## Click's Wrapping Behavior\n\nClick's default wrapping ignores single new lines and rewraps the text based on the width of the terminal to a maximum of 80 characters by default, but this can be modified with {attr}`~Context.max_content_width`. In the example notice how the second grouping of three lines is rewrapped into a single paragraph.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""\n This is a very long paragraph and as you\n can see wrapped very early in the source text\n but will be rewrapped to the terminal width in\n the final output.\n\n This is\n a paragraph\n that is compacted.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Escaping Click's Wrapping\n\nSometimes Click's wrapping can be a problem, such as when showing code examples where new lines are significant. This behavior can be escaped on a per-paragraph basis by adding a line with only `\\b` . The `\\b` is removed from the rendered help text.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n\n \\b\n This is\n a paragraph\n without rewrapping.\n\n And this is a paragraph\n that will be rewrapped again.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\nTo change the rendering maximum width, pass `max_content_width` when calling the command.\n\n```bash\ncli(max_content_width=120)\n```\n\n## Truncating Help Texts\n\nClick gets {class}`Command` help text from the docstring. If you do not want to include part of the docstring, add the `\\f` escape marker to have Click truncate the help text after the marker.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n \\f\n\n Words to not be included.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n(doc-meta-variables)=\n\n""]","[""# Help Pages\n\n```{currentmodule} click\n```\n\nClick makes it very easy to document your command line tools. For most things Click automatically generates help pages for you. By design the text is customizable, but the layout is not.\n\n## Help Texts\n\nCommands and options accept help arguments. For commands, the docstring of the function is automatically used if provided.\n\nSimple example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('name', help='The name to print.')\n @click.option('--count', default=1, help='number of greetings')\n def hello(name: str, count: int):\n \""\""\""This script prints hello and a name one or more times.\""\""\""\n for x in range(count):\n if name:\n click.echo(f\""Hello {name}!\"")\n else:\n click.echo(\""Hello!\"")\n\n.. click:run::\n invoke(hello, args=['--help'])\n```\n\n## Command Short Help\n\nFor subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with `...`. The short help snippet can also be overridden with `short_help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group()\n def cli():\n \""\""\""A simple command line tool.\""\""\""\n\n @cli.command('init', short_help='init the repo')\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Group Help Page\n\nThe group help prints sub commands, options, epilog help, and arguments, and prints them together.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group(\n help=\""Example Click app with subcommands, options, and positional arguments.\"",\n epilog=(\""Examples:\\n\\n\\b\\n python hello.py greet Alice --count 2\\n\""),\n )\n def cli() -> None:\n \""\""\""Run the example CLI.\""\""\""\n\n @cli.command()\n @click.argument(\""name\"")\n @click.option(\n \""--count\"",\n default=1,\n show_default=True,\n type=click.IntRange(1, None),\n help=\""Number of greetings to print.\"",\n )\n @click.option(\n \""--greeting\"",\n default=\""Hello\"",\n show_default=True,\n help=\""Greeting prefix to use.\"",\n )\n def greet(name: str, count: int, greeting: str) -> None:\n \""\""\""Greet NAME one or more times.\""\""\""\n for _ in range(count):\n click.echo(f\""{greeting} {name}!\"")\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Command Epilog Help\n\nThe help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command(\n epilog='See https://example.com for more details',\n )\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(init, args=['--help'])\n```\n\n(documenting-arguments)=\n\n## Documenting Arguments\n\n{class}`click.argument` accepts an optional `help` parameter that is shown in\nthe `Positional arguments` section of the help page. You can still document\narguments in the command docstring, especially when you want to describe them\nin the main help text by name.\n\nA brief example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename', help='The file to print.')\n def touch(filename):\n \""\""\""Print FILENAME.\""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\nOr more explicitly in the docstring:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename')\n def touch(filename):\n \""\""\""Print FILENAME.\n\n FILENAME is the name of the file to check.\n \""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\n"", ""## Placeholder / Meta Variable\n\nThe default placeholder variable ([meta variable](https://en.wikipedia.org/wiki/Metasyntactic_variable#IETF_Requests_for_Comments)) in the help pages is the parameter name in uppercase with underscores. This can be changed for Commands and Parameters with the `options_metavar` and `metavar` kwargs.\n\n```{eval-rst}\n.. click:example::\n\n # This controls entry on the usage line.\n @click.command(options_metavar='[[options]]')\n @click.option('--count', default=1, help='number of greetings',\n metavar='')\n @click.argument('name', metavar='')\n def hello(name: str, count: int) -> None:\n \""\""\""This script prints 'hello ' a total of times.\""\""\""\n for x in range(count):\n click.echo(f\""Hello {name}!\"")\n\n# Example usage:\n\n.. click:run::\n invoke(hello, args=['--help'])\n\n```\n\n```{admonition} Optional elements are bracketed\n:class: note\n\n The usage line follows a consistent convention: an element is optional when it is enclosed in square brackets and required when it appears outside them. A required argument appears as `FOO` and an optional one as `[FOO]`, with a variadic argument adding a trailing `...` (so `[FOO]...`). A single pair of brackets can group several tokens, so a chained group renders an extra command and its arguments as one optional, repeatable unit: `[COMMAND2 [ARGS]...]...`. A {class}`Group` that can run without naming a subcommand (`invoke_without_command=True`) also brackets the leading command, showing `[COMMAND]` instead of `COMMAND`. The `[OPTIONS]` placeholder is always bracketed, since adding options is itself optional.\n\n This mirrors the conventional utility-argument syntax for optional arguments and operands ([POSIX §12.1](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html), [`man-pages(7)`](https://man7.org/linux/man-pages/man7/man-pages.7.html)), where a bracketed expression followed by `...` denotes zero or more occurrences. A subcommand name is a positional operand, so Click brackets it under the same rule.\n```\n\n## Help Parameter Customization\n\nHelp parameters are automatically added by Click for any command. The default is `--help` but can be overridden by the context setting {attr}`~Context.help_option_names`. Click resolves conflicts automatically: an option reusing one of the help option names takes it over, and the default help parameter is dropped once all its names are taken. A parameter merely named `help`, like `click.argument(\""help\"")`, does not disable it: both keep working independently.\n\nThis example changes the default parameters to `-h` and `--help`\ninstead of just `--help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])\n\n @click.command(context_settings=CONTEXT_SETTINGS)\n def cli():\n pass\n\n.. click:run::\n invoke(cli, ['-h'])\n```\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""click-8.5.0/docs/documentation.md#codepoints:3805:7110"", ""revision"": ""8.5.0+sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34"", ""source_id"": ""click-8.5:documentation.md"", ""uri"": ""https://files.pythonhosted.org/packages/c7/0e/7fa0ef50764b67090eca4114772a2abf8b6148198475e54c660b97caeee6/click-8.5.0.tar.gz""}]" dp-rt-click-8.5-documentation.md-head1,dp-Click-documentation.md,Click 8.5.0 documentation: Group Help Page,"[""# Help Pages\n\n```{currentmodule} click\n```\n\nClick makes it very easy to document your command line tools. For most things Click automatically generates help pages for you. By design the text is customizable, but the layout is not.\n\n## Help Texts\n\nCommands and options accept help arguments. For commands, the docstring of the function is automatically used if provided.\n\nSimple example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('name', help='The name to print.')\n @click.option('--count', default=1, help='number of greetings')\n def hello(name: str, count: int):\n \""\""\""This script prints hello and a name one or more times.\""\""\""\n for x in range(count):\n if name:\n click.echo(f\""Hello {name}!\"")\n else:\n click.echo(\""Hello!\"")\n\n.. click:run::\n invoke(hello, args=['--help'])\n```\n\n## Command Short Help\n\nFor subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with `...`. The short help snippet can also be overridden with `short_help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group()\n def cli():\n \""\""\""A simple command line tool.\""\""\""\n\n @cli.command('init', short_help='init the repo')\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Group Help Page\n\nThe group help prints sub commands, options, epilog help, and arguments, and prints them together.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group(\n help=\""Example Click app with subcommands, options, and positional arguments.\"",\n epilog=(\""Examples:\\n\\n\\b\\n python hello.py greet Alice --count 2\\n\""),\n )\n def cli() -> None:\n \""\""\""Run the example CLI.\""\""\""\n\n @cli.command()\n @click.argument(\""name\"")\n @click.option(\n \""--count\"",\n default=1,\n show_default=True,\n type=click.IntRange(1, None),\n help=\""Number of greetings to print.\"",\n )\n @click.option(\n \""--greeting\"",\n default=\""Hello\"",\n show_default=True,\n help=\""Greeting prefix to use.\"",\n )\n def greet(name: str, count: int, greeting: str) -> None:\n \""\""\""Greet NAME one or more times.\""\""\""\n for _ in range(count):\n click.echo(f\""{greeting} {name}!\"")\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Command Epilog Help\n\nThe help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command(\n epilog='See https://example.com for more details',\n )\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(init, args=['--help'])\n```\n\n(documenting-arguments)=\n\n## Documenting Arguments\n\n{class}`click.argument` accepts an optional `help` parameter that is shown in\nthe `Positional arguments` section of the help page. You can still document\narguments in the command docstring, especially when you want to describe them\nin the main help text by name.\n\nA brief example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename', help='The file to print.')\n def touch(filename):\n \""\""\""Print FILENAME.\""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\nOr more explicitly in the docstring:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename')\n def touch(filename):\n \""\""\""Print FILENAME.\n\n FILENAME is the name of the file to check.\n \""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\n""]","[""## Placeholder / Meta Variable\n\nThe default placeholder variable ([meta variable](https://en.wikipedia.org/wiki/Metasyntactic_variable#IETF_Requests_for_Comments)) in the help pages is the parameter name in uppercase with underscores. This can be changed for Commands and Parameters with the `options_metavar` and `metavar` kwargs.\n\n```{eval-rst}\n.. click:example::\n\n # This controls entry on the usage line.\n @click.command(options_metavar='[[options]]')\n @click.option('--count', default=1, help='number of greetings',\n metavar='')\n @click.argument('name', metavar='')\n def hello(name: str, count: int) -> None:\n \""\""\""This script prints 'hello ' a total of times.\""\""\""\n for x in range(count):\n click.echo(f\""Hello {name}!\"")\n\n# Example usage:\n\n.. click:run::\n invoke(hello, args=['--help'])\n\n```\n\n```{admonition} Optional elements are bracketed\n:class: note\n\n The usage line follows a consistent convention: an element is optional when it is enclosed in square brackets and required when it appears outside them. A required argument appears as `FOO` and an optional one as `[FOO]`, with a variadic argument adding a trailing `...` (so `[FOO]...`). A single pair of brackets can group several tokens, so a chained group renders an extra command and its arguments as one optional, repeatable unit: `[COMMAND2 [ARGS]...]...`. A {class}`Group` that can run without naming a subcommand (`invoke_without_command=True`) also brackets the leading command, showing `[COMMAND]` instead of `COMMAND`. The `[OPTIONS]` placeholder is always bracketed, since adding options is itself optional.\n\n This mirrors the conventional utility-argument syntax for optional arguments and operands ([POSIX §12.1](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html), [`man-pages(7)`](https://man7.org/linux/man-pages/man7/man-pages.7.html)), where a bracketed expression followed by `...` denotes zero or more occurrences. A subcommand name is a positional operand, so Click brackets it under the same rule.\n```\n\n## Help Parameter Customization\n\nHelp parameters are automatically added by Click for any command. The default is `--help` but can be overridden by the context setting {attr}`~Context.help_option_names`. Click resolves conflicts automatically: an option reusing one of the help option names takes it over, and the default help parameter is dropped once all its names are taken. A parameter merely named `help`, like `click.argument(\""help\"")`, does not disable it: both keep working independently.\n\nThis example changes the default parameters to `-h` and `--help`\ninstead of just `--help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])\n\n @click.command(context_settings=CONTEXT_SETTINGS)\n def cli():\n pass\n\n.. click:run::\n invoke(cli, ['-h'])\n```\n"", ""## Showing Defaults\n\nTo control the appearance of defaults pass `show_default`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=False, help='number of dots')\n def dots(n):\n click.echo('.' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\nFor single option boolean flags, the default remains hidden if the default value is False, even if show default is set to true.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=True)\n @click.option(\""--gr\"", is_flag=True, show_default=True, default=False, help=\""Greet the world.\"")\n @click.option(\""--br\"", is_flag=True, show_default=True, default=True, help=\""Add a thematic break\"")\n def dots(n, gr, br):\n if gr:\n click.echo('Hello world!')\n click.echo('.' * n)\n if br:\n click.echo('-' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\n## Showing Environment Variables\n\nTo control the appearance of environment variables pass `show_envvar`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--username', envvar='USERNAME', show_envvar=True)\n def greet(username):\n click.echo(f'Hello {username}!')\n\n.. click:run::\n invoke(greet, args=['--help'])\n```\n\n## Click's Wrapping Behavior\n\nClick's default wrapping ignores single new lines and rewraps the text based on the width of the terminal to a maximum of 80 characters by default, but this can be modified with {attr}`~Context.max_content_width`. In the example notice how the second grouping of three lines is rewrapped into a single paragraph.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""\n This is a very long paragraph and as you\n can see wrapped very early in the source text\n but will be rewrapped to the terminal width in\n the final output.\n\n This is\n a paragraph\n that is compacted.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Escaping Click's Wrapping\n\nSometimes Click's wrapping can be a problem, such as when showing code examples where new lines are significant. This behavior can be escaped on a per-paragraph basis by adding a line with only `\\b` . The `\\b` is removed from the rendered help text.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n\n \\b\n This is\n a paragraph\n without rewrapping.\n\n And this is a paragraph\n that will be rewrapped again.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\nTo change the rendering maximum width, pass `max_content_width` when calling the command.\n\n```bash\ncli(max_content_width=120)\n```\n\n## Truncating Help Texts\n\nClick gets {class}`Command` help text from the docstring. If you do not want to include part of the docstring, add the `\\f` escape marker to have Click truncate the help text after the marker.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n \\f\n\n Words to not be included.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n(doc-meta-variables)=\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""click-8.5.0/docs/documentation.md#codepoints:0:3805"", ""revision"": ""8.5.0+sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34"", ""source_id"": ""click-8.5:documentation.md"", ""uri"": ""https://files.pythonhosted.org/packages/c7/0e/7fa0ef50764b67090eca4114772a2abf8b6148198475e54c660b97caeee6/click-8.5.0.tar.gz""}]" dp-rt-click-8.5-documentation.md-head2,dp-Click-documentation.md,Click 8.5.0 documentation: Help Pages,"[""# Help Pages\n\n```{currentmodule} click\n```\n\nClick makes it very easy to document your command line tools. For most things Click automatically generates help pages for you. By design the text is customizable, but the layout is not.\n\n## Help Texts\n\nCommands and options accept help arguments. For commands, the docstring of the function is automatically used if provided.\n\nSimple example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('name', help='The name to print.')\n @click.option('--count', default=1, help='number of greetings')\n def hello(name: str, count: int):\n \""\""\""This script prints hello and a name one or more times.\""\""\""\n for x in range(count):\n if name:\n click.echo(f\""Hello {name}!\"")\n else:\n click.echo(\""Hello!\"")\n\n.. click:run::\n invoke(hello, args=['--help'])\n```\n\n## Command Short Help\n\nFor subcommands, a short help snippet is generated. By default, it's the first sentence of the docstring. If too long, then it will ellipsize what cannot be fit on a single line with `...`. The short help snippet can also be overridden with `short_help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group()\n def cli():\n \""\""\""A simple command line tool.\""\""\""\n\n @cli.command('init', short_help='init the repo')\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Group Help Page\n\nThe group help prints sub commands, options, epilog help, and arguments, and prints them together.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.group(\n help=\""Example Click app with subcommands, options, and positional arguments.\"",\n epilog=(\""Examples:\\n\\n\\b\\n python hello.py greet Alice --count 2\\n\""),\n )\n def cli() -> None:\n \""\""\""Run the example CLI.\""\""\""\n\n @cli.command()\n @click.argument(\""name\"")\n @click.option(\n \""--count\"",\n default=1,\n show_default=True,\n type=click.IntRange(1, None),\n help=\""Number of greetings to print.\"",\n )\n @click.option(\n \""--greeting\"",\n default=\""Hello\"",\n show_default=True,\n help=\""Greeting prefix to use.\"",\n )\n def greet(name: str, count: int, greeting: str) -> None:\n \""\""\""Greet NAME one or more times.\""\""\""\n for _ in range(count):\n click.echo(f\""{greeting} {name}!\"")\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Command Epilog Help\n\nThe help epilog is printed at the end of the help and is useful for showing example command usages or referencing additional help resources.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command(\n epilog='See https://example.com for more details',\n )\n def init():\n \""\""\""Initializes the repository.\""\""\""\n\n.. click:run::\n invoke(init, args=['--help'])\n```\n\n(documenting-arguments)=\n\n## Documenting Arguments\n\n{class}`click.argument` accepts an optional `help` parameter that is shown in\nthe `Positional arguments` section of the help page. You can still document\narguments in the command docstring, especially when you want to describe them\nin the main help text by name.\n\nA brief example:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename', help='The file to print.')\n def touch(filename):\n \""\""\""Print FILENAME.\""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\nOr more explicitly in the docstring:\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.argument('filename')\n def touch(filename):\n \""\""\""Print FILENAME.\n\n FILENAME is the name of the file to check.\n \""\""\""\n click.echo(filename)\n\n.. click:run::\n invoke(touch, args=['--help'])\n```\n\n""]","[""## Placeholder / Meta Variable\n\nThe default placeholder variable ([meta variable](https://en.wikipedia.org/wiki/Metasyntactic_variable#IETF_Requests_for_Comments)) in the help pages is the parameter name in uppercase with underscores. This can be changed for Commands and Parameters with the `options_metavar` and `metavar` kwargs.\n\n```{eval-rst}\n.. click:example::\n\n # This controls entry on the usage line.\n @click.command(options_metavar='[[options]]')\n @click.option('--count', default=1, help='number of greetings',\n metavar='')\n @click.argument('name', metavar='')\n def hello(name: str, count: int) -> None:\n \""\""\""This script prints 'hello ' a total of times.\""\""\""\n for x in range(count):\n click.echo(f\""Hello {name}!\"")\n\n# Example usage:\n\n.. click:run::\n invoke(hello, args=['--help'])\n\n```\n\n```{admonition} Optional elements are bracketed\n:class: note\n\n The usage line follows a consistent convention: an element is optional when it is enclosed in square brackets and required when it appears outside them. A required argument appears as `FOO` and an optional one as `[FOO]`, with a variadic argument adding a trailing `...` (so `[FOO]...`). A single pair of brackets can group several tokens, so a chained group renders an extra command and its arguments as one optional, repeatable unit: `[COMMAND2 [ARGS]...]...`. A {class}`Group` that can run without naming a subcommand (`invoke_without_command=True`) also brackets the leading command, showing `[COMMAND]` instead of `COMMAND`. The `[OPTIONS]` placeholder is always bracketed, since adding options is itself optional.\n\n This mirrors the conventional utility-argument syntax for optional arguments and operands ([POSIX §12.1](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html), [`man-pages(7)`](https://man7.org/linux/man-pages/man7/man-pages.7.html)), where a bracketed expression followed by `...` denotes zero or more occurrences. A subcommand name is a positional operand, so Click brackets it under the same rule.\n```\n\n## Help Parameter Customization\n\nHelp parameters are automatically added by Click for any command. The default is `--help` but can be overridden by the context setting {attr}`~Context.help_option_names`. Click resolves conflicts automatically: an option reusing one of the help option names takes it over, and the default help parameter is dropped once all its names are taken. A parameter merely named `help`, like `click.argument(\""help\"")`, does not disable it: both keep working independently.\n\nThis example changes the default parameters to `-h` and `--help`\ninstead of just `--help`:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])\n\n @click.command(context_settings=CONTEXT_SETTINGS)\n def cli():\n pass\n\n.. click:run::\n invoke(cli, ['-h'])\n```\n"", ""## Showing Defaults\n\nTo control the appearance of defaults pass `show_default`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=False, help='number of dots')\n def dots(n):\n click.echo('.' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\nFor single option boolean flags, the default remains hidden if the default value is False, even if show default is set to true.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--n', default=1, show_default=True)\n @click.option(\""--gr\"", is_flag=True, show_default=True, default=False, help=\""Greet the world.\"")\n @click.option(\""--br\"", is_flag=True, show_default=True, default=True, help=\""Add a thematic break\"")\n def dots(n, gr, br):\n if gr:\n click.echo('Hello world!')\n click.echo('.' * n)\n if br:\n click.echo('-' * n)\n\n.. click:run::\n invoke(dots, args=['--help'])\n```\n\n## Showing Environment Variables\n\nTo control the appearance of environment variables pass `show_envvar`.\n\n```{eval-rst}\n.. click:example::\n\n @click.command()\n @click.option('--username', envvar='USERNAME', show_envvar=True)\n def greet(username):\n click.echo(f'Hello {username}!')\n\n.. click:run::\n invoke(greet, args=['--help'])\n```\n\n## Click's Wrapping Behavior\n\nClick's default wrapping ignores single new lines and rewraps the text based on the width of the terminal to a maximum of 80 characters by default, but this can be modified with {attr}`~Context.max_content_width`. In the example notice how the second grouping of three lines is rewrapped into a single paragraph.\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""\n This is a very long paragraph and as you\n can see wrapped very early in the source text\n but will be rewrapped to the terminal width in\n the final output.\n\n This is\n a paragraph\n that is compacted.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n## Escaping Click's Wrapping\n\nSometimes Click's wrapping can be a problem, such as when showing code examples where new lines are significant. This behavior can be escaped on a per-paragraph basis by adding a line with only `\\b` . The `\\b` is removed from the rendered help text.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n\n \\b\n This is\n a paragraph\n without rewrapping.\n\n And this is a paragraph\n that will be rewrapped again.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\nTo change the rendering maximum width, pass `max_content_width` when calling the command.\n\n```bash\ncli(max_content_width=120)\n```\n\n## Truncating Help Texts\n\nClick gets {class}`Command` help text from the docstring. If you do not want to include part of the docstring, add the `\\f` escape marker to have Click truncate the help text after the marker.\n\nExample:\n\n```{eval-rst}\n.. click:example::\n\n import click\n\n @click.command()\n def cli():\n \""\""\""First paragraph.\n \\f\n\n Words to not be included.\n \""\""\""\n\n.. click:run::\n invoke(cli, args=['--help'])\n```\n\n(doc-meta-variables)=\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""click-8.5.0/docs/documentation.md#codepoints:0:3805"", ""revision"": ""8.5.0+sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34"", ""source_id"": ""click-8.5:documentation.md"", ""uri"": ""https://files.pythonhosted.org/packages/c7/0e/7fa0ef50764b67090eca4114772a2abf8b6148198475e54c660b97caeee6/click-8.5.0.tar.gz""}]" dp-rt-flask-3.1-deploying-eventlet.rst-head0,dp-Flask-deploying-eventlet.rst,Flask 3.1.3 documentation: eventlet,"["":orphan:\n\neventlet\n========\n\n`Eventlet is no longer maintained.`__ Use :doc:`/deploying/gevent` instead.\n\n__ https://eventlet.readthedocs.io\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/deploying/eventlet.rst#codepoints:0:141"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:deploying/eventlet.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-deploying-nginx.rst-head0,dp-Flask-deploying-nginx.rst,Flask 3.1.3 documentation: Configuration,"[""nginx\n=====\n\n`nginx`_ is a fast, production level HTTP server. When serving your\napplication with one of the WSGI servers listed in :doc:`index`, it is\noften good or necessary to put a dedicated HTTP server in front of it.\nThis \""reverse proxy\"" can handle incoming requests, TLS, and other\nsecurity and performance concerns better than the WSGI server.\n\nNginx can be installed using your system package manager, or a pre-built\nexecutable for Windows. Installing and running Nginx itself is outside\nthe scope of this doc. This page outlines the basics of configuring\nNginx to proxy your application. Be sure to read its documentation to\nunderstand what features are available.\n\n.. _nginx: https://nginx.org/\n\n\nDomain Name\n-----------\n\nAcquiring and configuring a domain name is outside the scope of this\ndoc. In general, you will buy a domain name from a registrar, pay for\nserver space with a hosting provider, and then point your registrar\nat the hosting provider's name servers.\n\nTo simulate this, you can also edit your ``hosts`` file, located at\n``/etc/hosts`` on Linux. Add a line that associates a name with the\nlocal IP.\n\nModern Linux systems may be configured to treat any domain name that\nends with ``.localhost`` like this without adding it to the ``hosts``\nfile.\n\n.. code-block:: python\n :caption: ``/etc/hosts``\n\n 127.0.0.1 hello.localhost\n\n\nConfiguration\n-------------\n\nThe nginx configuration is located at ``/etc/nginx/nginx.conf`` on\nLinux. It may be different depending on your operating system. Check the\ndocs and look for ``nginx.conf``.\n\nRemove or comment out any existing ``server`` section. Add a ``server``\nsection and use the ``proxy_pass`` directive to point to the address the\nWSGI server is listening on. We'll assume the WSGI server is listening\nlocally at ``http://127.0.0.1:8000``.\n\n.. code-block:: nginx\n :caption: ``/etc/nginx.conf``\n\n server {\n listen 80;\n server_name _;\n\n location / {\n proxy_pass http://127.0.0.1:8000/;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header X-Forwarded-Host $host;\n proxy_set_header X-Forwarded-Prefix /;\n }\n }\n\nThen :doc:`proxy_fix` so that your application uses these headers.\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/deploying/nginx.rst#codepoints:0:2316"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:deploying/nginx.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-deploying-nginx.rst-head1,dp-Flask-deploying-nginx.rst,Flask 3.1.3 documentation: Domain Name,"[""nginx\n=====\n\n`nginx`_ is a fast, production level HTTP server. When serving your\napplication with one of the WSGI servers listed in :doc:`index`, it is\noften good or necessary to put a dedicated HTTP server in front of it.\nThis \""reverse proxy\"" can handle incoming requests, TLS, and other\nsecurity and performance concerns better than the WSGI server.\n\nNginx can be installed using your system package manager, or a pre-built\nexecutable for Windows. Installing and running Nginx itself is outside\nthe scope of this doc. This page outlines the basics of configuring\nNginx to proxy your application. Be sure to read its documentation to\nunderstand what features are available.\n\n.. _nginx: https://nginx.org/\n\n\nDomain Name\n-----------\n\nAcquiring and configuring a domain name is outside the scope of this\ndoc. In general, you will buy a domain name from a registrar, pay for\nserver space with a hosting provider, and then point your registrar\nat the hosting provider's name servers.\n\nTo simulate this, you can also edit your ``hosts`` file, located at\n``/etc/hosts`` on Linux. Add a line that associates a name with the\nlocal IP.\n\nModern Linux systems may be configured to treat any domain name that\nends with ``.localhost`` like this without adding it to the ``hosts``\nfile.\n\n.. code-block:: python\n :caption: ``/etc/hosts``\n\n 127.0.0.1 hello.localhost\n\n\nConfiguration\n-------------\n\nThe nginx configuration is located at ``/etc/nginx/nginx.conf`` on\nLinux. It may be different depending on your operating system. Check the\ndocs and look for ``nginx.conf``.\n\nRemove or comment out any existing ``server`` section. Add a ``server``\nsection and use the ``proxy_pass`` directive to point to the address the\nWSGI server is listening on. We'll assume the WSGI server is listening\nlocally at ``http://127.0.0.1:8000``.\n\n.. code-block:: nginx\n :caption: ``/etc/nginx.conf``\n\n server {\n listen 80;\n server_name _;\n\n location / {\n proxy_pass http://127.0.0.1:8000/;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_set_header X-Forwarded-Host $host;\n proxy_set_header X-Forwarded-Prefix /;\n }\n }\n\nThen :doc:`proxy_fix` so that your application uses these headers.\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/deploying/nginx.rst#codepoints:0:2316"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:deploying/nginx.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-deploying-proxy_fix.rst-head0,dp-Flask-deploying-proxy_fix.rst,Flask 3.1.3 documentation: Tell Flask it is Behind a Proxy,"[""Tell Flask it is Behind a Proxy\n===============================\n\nWhen using a reverse proxy, or many Python hosting platforms, the proxy\nwill intercept and forward all external requests to the local WSGI\nserver.\n\nFrom the WSGI server and Flask application's perspectives, requests are\nnow coming from the HTTP server to the local address, rather than from\nthe remote address to the external server address.\n\nHTTP servers should set ``X-Forwarded-`` headers to pass on the real\nvalues to the application. The application can then be told to trust and\nuse those values by wrapping it with the\n:doc:`werkzeug:middleware/proxy_fix` middleware provided by Werkzeug.\n\nThis middleware should only be used if the application is actually\nbehind a proxy, and should be configured with the number of proxies that\nare chained in front of it. Not all proxies set all the headers. Since\nincoming headers can be faked, you must set how many proxies are setting\neach header so the middleware knows what to trust.\n\n.. code-block:: python\n\n from werkzeug.middleware.proxy_fix import ProxyFix\n\n app.wsgi_app = ProxyFix(\n app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1\n )\n\nRemember, only apply this middleware if you are behind a proxy, and set\nthe correct number of proxies that set each header. It can be a security\nissue if you get this configuration wrong.\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/deploying/proxy_fix.rst#codepoints:0:1365"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:deploying/proxy_fix.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-design.rst-head0,dp-Flask-design.rst,Flask 3.1.3 documentation: One Template Engine,"[""The Routing System\n------------------\n\nFlask uses the Werkzeug routing system which was designed to\nautomatically order routes by complexity. This means that you can declare\nroutes in arbitrary order and they will still work as expected. This is a\nrequirement if you want to properly implement decorator based routing\nsince decorators could be fired in undefined order when the application is\nsplit into multiple modules.\n\nAnother design decision with the Werkzeug routing system is that routes\nin Werkzeug try to ensure that URLs are unique. Werkzeug will go quite far\nwith that in that it will automatically redirect to a canonical URL if a route\nis ambiguous.\n\n\nOne Template Engine\n-------------------\n\nFlask decides on one template engine: Jinja. Why doesn't Flask have a\npluggable template engine interface? You can obviously use a different\ntemplate engine, but Flask will still configure Jinja for you. While\nthat limitation that Jinja is *always* configured will probably go away,\nthe decision to bundle one template engine and use that will not.\n\nTemplate engines are like programming languages and each of those engines\nhas a certain understanding about how things work. On the surface they\nall work the same: you tell the engine to evaluate a template with a set\nof variables and take the return value as string.\n\nBut that's about where similarities end. Jinja for example has an\nextensive filter system, a certain way to do template inheritance,\nsupport for reusable blocks (macros) that can be used from inside\ntemplates and also from Python code, supports iterative template\nrendering, configurable syntax and more. On the other hand an engine\nlike Genshi is based on XML stream evaluation, template inheritance by\ntaking the availability of XPath into account and more. Mako on the\nother hand treats templates similar to Python modules.\n\nWhen it comes to connecting a template engine with an application or\nframework there is more than just rendering templates. For instance,\nFlask uses Jinja's extensive autoescaping support. Also it provides\nways to access macros from Jinja templates.\n\nA template abstraction layer that would not take the unique features of\nthe template engines away is a science on its own and a too large\nundertaking for a microframework like Flask.\n\nFurthermore extensions can then easily depend on one template language\nbeing present. You can easily use your own templating language, but an\nextension could still depend on Jinja itself.\n\n\n""]","[""What Flask is, What Flask is Not\n--------------------------------\n\nFlask will never have a database layer. It will not have a form library\nor anything else in that direction. Flask itself just bridges to Werkzeug\nto implement a proper WSGI application and to Jinja to handle templating.\nIt also binds to a few common standard library packages such as logging.\nEverything else is up for extensions.\n\nWhy is this the case? Because people have different preferences and\nrequirements and Flask could not meet those if it would force any of this\ninto the core. The majority of web applications will need a template\nengine in some sort. However not every application needs a SQL database.\n\nAs your codebase grows, you are free to make the design decisions appropriate\nfor your project. Flask will continue to provide a very simple glue layer to\nthe best that Python has to offer. You can implement advanced patterns in\nSQLAlchemy or another database tool, introduce non-relational data persistence\nas appropriate, and take advantage of framework-agnostic tools built for WSGI,\nthe Python web interface.\n\nThe idea of Flask is to build a good foundation for all applications.\nEverything else is up to you or extensions.\n"", ""Design Decisions in Flask\n=========================\n\nIf you are curious why Flask does certain things the way it does and not\ndifferently, this section is for you. This should give you an idea about\nsome of the design decisions that may appear arbitrary and surprising at\nfirst, especially in direct comparison with other frameworks.\n\n\nThe Explicit Application Object\n-------------------------------\n\nA Python web application based on WSGI has to have one central callable\nobject that implements the actual application. In Flask this is an\ninstance of the :class:`~flask.Flask` class. Each Flask application has\nto create an instance of this class itself and pass it the name of the\nmodule, but why can't Flask do that itself?\n\nWithout such an explicit application object the following code::\n\n from flask import Flask\n app = Flask(__name__)\n\n @app.route('/')\n def index():\n return 'Hello World!'\n\nWould look like this instead::\n\n from hypothetical_flask import route\n\n @route('/')\n def index():\n return 'Hello World!'\n\nThere are three major reasons for this. The most important one is that\nimplicit application objects require that there may only be one instance at\nthe time. There are ways to fake multiple applications with a single\napplication object, like maintaining a stack of applications, but this\ncauses some problems I won't outline here in detail. Now the question is:\nwhen does a microframework need more than one application at the same\ntime? A good example for this is unit testing. When you want to test\nsomething it can be very helpful to create a minimal application to test\nspecific behavior. When the application object is deleted everything it\nallocated will be freed again.\n\nAnother thing that becomes possible when you have an explicit object lying\naround in your code is that you can subclass the base class\n(:class:`~flask.Flask`) to alter specific behavior. This would not be\npossible without hacks if the object were created ahead of time for you\nbased on a class that is not exposed to you.\n\nBut there is another very important reason why Flask depends on an\nexplicit instantiation of that class: the package name. Whenever you\ncreate a Flask instance you usually pass it `__name__` as package name.\nFlask depends on that information to properly load resources relative\nto your module. With Python's outstanding support for reflection it can\nthen access the package to figure out where the templates and static files\nare stored (see :meth:`~flask.Flask.open_resource`). Now obviously there\nare frameworks around that do not need any configuration and will still be\nable to load templates relative to your application module. But they have\nto use the current working directory for that, which is a very unreliable\nway to determine where the application is. The current working directory\nis process-wide and if you are running multiple applications in one\nprocess (which could happen in a webserver without you knowing) the paths\nwill be off. Worse: many webservers do not set the working directory to\nthe directory of your application but to the document root which does not\nhave to be the same folder.\n\nThe third reason is \""explicit is better than implicit\"". That object is\nyour WSGI application, you don't have to remember anything else. If you\nwant to apply a WSGI middleware, just wrap it and you're done (though\nthere are better ways to do that so that you do not lose the reference\nto the application object :meth:`~flask.Flask.wsgi_app`).\n\nFurthermore this design makes it possible to use a factory function to\ncreate the application which is very helpful for unit testing and similar\nthings (:doc:`/patterns/appfactories`).\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/design.rst#codepoints:3713:6201"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:design.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-design.rst-head1,dp-Flask-design.rst,Flask 3.1.3 documentation: The Routing System,"[""The Routing System\n------------------\n\nFlask uses the Werkzeug routing system which was designed to\nautomatically order routes by complexity. This means that you can declare\nroutes in arbitrary order and they will still work as expected. This is a\nrequirement if you want to properly implement decorator based routing\nsince decorators could be fired in undefined order when the application is\nsplit into multiple modules.\n\nAnother design decision with the Werkzeug routing system is that routes\nin Werkzeug try to ensure that URLs are unique. Werkzeug will go quite far\nwith that in that it will automatically redirect to a canonical URL if a route\nis ambiguous.\n\n\nOne Template Engine\n-------------------\n\nFlask decides on one template engine: Jinja. Why doesn't Flask have a\npluggable template engine interface? You can obviously use a different\ntemplate engine, but Flask will still configure Jinja for you. While\nthat limitation that Jinja is *always* configured will probably go away,\nthe decision to bundle one template engine and use that will not.\n\nTemplate engines are like programming languages and each of those engines\nhas a certain understanding about how things work. On the surface they\nall work the same: you tell the engine to evaluate a template with a set\nof variables and take the return value as string.\n\nBut that's about where similarities end. Jinja for example has an\nextensive filter system, a certain way to do template inheritance,\nsupport for reusable blocks (macros) that can be used from inside\ntemplates and also from Python code, supports iterative template\nrendering, configurable syntax and more. On the other hand an engine\nlike Genshi is based on XML stream evaluation, template inheritance by\ntaking the availability of XPath into account and more. Mako on the\nother hand treats templates similar to Python modules.\n\nWhen it comes to connecting a template engine with an application or\nframework there is more than just rendering templates. For instance,\nFlask uses Jinja's extensive autoescaping support. Also it provides\nways to access macros from Jinja templates.\n\nA template abstraction layer that would not take the unique features of\nthe template engines away is a science on its own and a too large\nundertaking for a microframework like Flask.\n\nFurthermore extensions can then easily depend on one template language\nbeing present. You can easily use your own templating language, but an\nextension could still depend on Jinja itself.\n\n\n""]","[""Design Decisions in Flask\n=========================\n\nIf you are curious why Flask does certain things the way it does and not\ndifferently, this section is for you. This should give you an idea about\nsome of the design decisions that may appear arbitrary and surprising at\nfirst, especially in direct comparison with other frameworks.\n\n\nThe Explicit Application Object\n-------------------------------\n\nA Python web application based on WSGI has to have one central callable\nobject that implements the actual application. In Flask this is an\ninstance of the :class:`~flask.Flask` class. Each Flask application has\nto create an instance of this class itself and pass it the name of the\nmodule, but why can't Flask do that itself?\n\nWithout such an explicit application object the following code::\n\n from flask import Flask\n app = Flask(__name__)\n\n @app.route('/')\n def index():\n return 'Hello World!'\n\nWould look like this instead::\n\n from hypothetical_flask import route\n\n @route('/')\n def index():\n return 'Hello World!'\n\nThere are three major reasons for this. The most important one is that\nimplicit application objects require that there may only be one instance at\nthe time. There are ways to fake multiple applications with a single\napplication object, like maintaining a stack of applications, but this\ncauses some problems I won't outline here in detail. Now the question is:\nwhen does a microframework need more than one application at the same\ntime? A good example for this is unit testing. When you want to test\nsomething it can be very helpful to create a minimal application to test\nspecific behavior. When the application object is deleted everything it\nallocated will be freed again.\n\nAnother thing that becomes possible when you have an explicit object lying\naround in your code is that you can subclass the base class\n(:class:`~flask.Flask`) to alter specific behavior. This would not be\npossible without hacks if the object were created ahead of time for you\nbased on a class that is not exposed to you.\n\nBut there is another very important reason why Flask depends on an\nexplicit instantiation of that class: the package name. Whenever you\ncreate a Flask instance you usually pass it `__name__` as package name.\nFlask depends on that information to properly load resources relative\nto your module. With Python's outstanding support for reflection it can\nthen access the package to figure out where the templates and static files\nare stored (see :meth:`~flask.Flask.open_resource`). Now obviously there\nare frameworks around that do not need any configuration and will still be\nable to load templates relative to your application module. But they have\nto use the current working directory for that, which is a very unreliable\nway to determine where the application is. The current working directory\nis process-wide and if you are running multiple applications in one\nprocess (which could happen in a webserver without you knowing) the paths\nwill be off. Worse: many webservers do not set the working directory to\nthe directory of your application but to the document root which does not\nhave to be the same folder.\n\nThe third reason is \""explicit is better than implicit\"". That object is\nyour WSGI application, you don't have to remember anything else. If you\nwant to apply a WSGI middleware, just wrap it and you're done (though\nthere are better ways to do that so that you do not lose the reference\nto the application object :meth:`~flask.Flask.wsgi_app`).\n\nFurthermore this design makes it possible to use a factory function to\ncreate the application which is very helpful for unit testing and similar\nthings (:doc:`/patterns/appfactories`).\n\n"", ""What does \""micro\"" mean?\n-----------------------\n\n“Micro” does not mean that your whole web application has to fit into a single\nPython file (although it certainly can), nor does it mean that Flask is lacking\nin functionality. The \""micro\"" in microframework means Flask aims to keep the\ncore simple but extensible. Flask won't make many decisions for you, such as\nwhat database to use. Those decisions that it does make, such as what\ntemplating engine to use, are easy to change. Everything else is up to you, so\nthat Flask can be everything you need and nothing you don't.\n\nBy default, Flask does not include a database abstraction layer, form\nvalidation or anything else where different libraries already exist that can\nhandle that. Instead, Flask supports extensions to add such functionality to\nyour application as if it was implemented in Flask itself. Numerous extensions\nprovide database integration, form validation, upload handling, various open\nauthentication technologies, and more. Flask may be \""micro\"", but it's ready for\nproduction use on a variety of needs.\n\nWhy does Flask call itself a microframework and yet it depends on two\nlibraries (namely Werkzeug and Jinja). Why shouldn't it? If we look\nover to the Ruby side of web development there we have a protocol very\nsimilar to WSGI. Just that it's called Rack there, but besides that it\nlooks very much like a WSGI rendition for Ruby. But nearly all\napplications in Ruby land do not work with Rack directly, but on top of a\nlibrary with the same name. This Rack library has two equivalents in\nPython: WebOb (formerly Paste) and Werkzeug. Paste is still around but\nfrom my understanding it's sort of deprecated in favour of WebOb. The\ndevelopment of WebOb and Werkzeug started side by side with similar ideas\nin mind: be a good implementation of WSGI for other applications to take\nadvantage.\n\nFlask is a framework that takes advantage of the work already done by\nWerkzeug to properly interface WSGI (which can be a complex task at\ntimes). Thanks to recent developments in the Python package\ninfrastructure, packages with dependencies are no longer an issue and\nthere are very few reasons against having libraries that depend on others.\n\n\nThread Locals\n-------------\n\nFlask uses thread local objects (context local objects in fact, they\nsupport greenlet contexts as well) for request, session and an extra\nobject you can put your own things on (:data:`~flask.g`). Why is that and\nisn't that a bad idea?\n\nYes it is usually not such a bright idea to use thread locals. They cause\ntroubles for servers that are not based on the concept of threads and make\nlarge applications harder to maintain. However Flask is just not designed\nfor large applications or asynchronous servers. Flask wants to make it\nquick and easy to write a traditional web application.\n\n\nAsync/await and ASGI support\n----------------------------\n\nFlask supports ``async`` coroutines for view functions by executing the\ncoroutine on a separate thread instead of using an event loop on the\nmain thread as an async-first (ASGI) framework would. This is necessary\nfor Flask to remain backwards compatible with extensions and code built\nbefore ``async`` was introduced into Python. This compromise introduces\na performance cost compared with the ASGI frameworks, due to the\noverhead of the threads.\n\nDue to how tied to WSGI Flask's code is, it's not clear if it's possible\nto make the ``Flask`` class support ASGI and WSGI at the same time. Work\nis currently being done in Werkzeug to work with ASGI, which may\neventually enable support in Flask as well.\n\nSee :doc:`/async-await` for more discussion.\n\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/design.rst#codepoints:3713:6201"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:design.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-design.rst-head2,dp-Flask-design.rst,"Flask 3.1.3 documentation: What does ""micro"" mean?","[""What does \""micro\"" mean?\n-----------------------\n\n“Micro” does not mean that your whole web application has to fit into a single\nPython file (although it certainly can), nor does it mean that Flask is lacking\nin functionality. The \""micro\"" in microframework means Flask aims to keep the\ncore simple but extensible. Flask won't make many decisions for you, such as\nwhat database to use. Those decisions that it does make, such as what\ntemplating engine to use, are easy to change. Everything else is up to you, so\nthat Flask can be everything you need and nothing you don't.\n\nBy default, Flask does not include a database abstraction layer, form\nvalidation or anything else where different libraries already exist that can\nhandle that. Instead, Flask supports extensions to add such functionality to\nyour application as if it was implemented in Flask itself. Numerous extensions\nprovide database integration, form validation, upload handling, various open\nauthentication technologies, and more. Flask may be \""micro\"", but it's ready for\nproduction use on a variety of needs.\n\nWhy does Flask call itself a microframework and yet it depends on two\nlibraries (namely Werkzeug and Jinja). Why shouldn't it? If we look\nover to the Ruby side of web development there we have a protocol very\nsimilar to WSGI. Just that it's called Rack there, but besides that it\nlooks very much like a WSGI rendition for Ruby. But nearly all\napplications in Ruby land do not work with Rack directly, but on top of a\nlibrary with the same name. This Rack library has two equivalents in\nPython: WebOb (formerly Paste) and Werkzeug. Paste is still around but\nfrom my understanding it's sort of deprecated in favour of WebOb. The\ndevelopment of WebOb and Werkzeug started side by side with similar ideas\nin mind: be a good implementation of WSGI for other applications to take\nadvantage.\n\nFlask is a framework that takes advantage of the work already done by\nWerkzeug to properly interface WSGI (which can be a complex task at\ntimes). Thanks to recent developments in the Python package\ninfrastructure, packages with dependencies are no longer an issue and\nthere are very few reasons against having libraries that depend on others.\n\n\nThread Locals\n-------------\n\nFlask uses thread local objects (context local objects in fact, they\nsupport greenlet contexts as well) for request, session and an extra\nobject you can put your own things on (:data:`~flask.g`). Why is that and\nisn't that a bad idea?\n\nYes it is usually not such a bright idea to use thread locals. They cause\ntroubles for servers that are not based on the concept of threads and make\nlarge applications harder to maintain. However Flask is just not designed\nfor large applications or asynchronous servers. Flask wants to make it\nquick and easy to write a traditional web application.\n\n\nAsync/await and ASGI support\n----------------------------\n\nFlask supports ``async`` coroutines for view functions by executing the\ncoroutine on a separate thread instead of using an event loop on the\nmain thread as an async-first (ASGI) framework would. This is necessary\nfor Flask to remain backwards compatible with extensions and code built\nbefore ``async`` was introduced into Python. This compromise introduces\na performance cost compared with the ASGI frameworks, due to the\noverhead of the threads.\n\nDue to how tied to WSGI Flask's code is, it's not clear if it's possible\nto make the ``Flask`` class support ASGI and WSGI at the same time. Work\nis currently being done in Werkzeug to work with ASGI, which may\neventually enable support in Flask as well.\n\nSee :doc:`/async-await` for more discussion.\n\n\n""]","[""Design Decisions in Flask\n=========================\n\nIf you are curious why Flask does certain things the way it does and not\ndifferently, this section is for you. This should give you an idea about\nsome of the design decisions that may appear arbitrary and surprising at\nfirst, especially in direct comparison with other frameworks.\n\n\nThe Explicit Application Object\n-------------------------------\n\nA Python web application based on WSGI has to have one central callable\nobject that implements the actual application. In Flask this is an\ninstance of the :class:`~flask.Flask` class. Each Flask application has\nto create an instance of this class itself and pass it the name of the\nmodule, but why can't Flask do that itself?\n\nWithout such an explicit application object the following code::\n\n from flask import Flask\n app = Flask(__name__)\n\n @app.route('/')\n def index():\n return 'Hello World!'\n\nWould look like this instead::\n\n from hypothetical_flask import route\n\n @route('/')\n def index():\n return 'Hello World!'\n\nThere are three major reasons for this. The most important one is that\nimplicit application objects require that there may only be one instance at\nthe time. There are ways to fake multiple applications with a single\napplication object, like maintaining a stack of applications, but this\ncauses some problems I won't outline here in detail. Now the question is:\nwhen does a microframework need more than one application at the same\ntime? A good example for this is unit testing. When you want to test\nsomething it can be very helpful to create a minimal application to test\nspecific behavior. When the application object is deleted everything it\nallocated will be freed again.\n\nAnother thing that becomes possible when you have an explicit object lying\naround in your code is that you can subclass the base class\n(:class:`~flask.Flask`) to alter specific behavior. This would not be\npossible without hacks if the object were created ahead of time for you\nbased on a class that is not exposed to you.\n\nBut there is another very important reason why Flask depends on an\nexplicit instantiation of that class: the package name. Whenever you\ncreate a Flask instance you usually pass it `__name__` as package name.\nFlask depends on that information to properly load resources relative\nto your module. With Python's outstanding support for reflection it can\nthen access the package to figure out where the templates and static files\nare stored (see :meth:`~flask.Flask.open_resource`). Now obviously there\nare frameworks around that do not need any configuration and will still be\nable to load templates relative to your application module. But they have\nto use the current working directory for that, which is a very unreliable\nway to determine where the application is. The current working directory\nis process-wide and if you are running multiple applications in one\nprocess (which could happen in a webserver without you knowing) the paths\nwill be off. Worse: many webservers do not set the working directory to\nthe directory of your application but to the document root which does not\nhave to be the same folder.\n\nThe third reason is \""explicit is better than implicit\"". That object is\nyour WSGI application, you don't have to remember anything else. If you\nwant to apply a WSGI middleware, just wrap it and you're done (though\nthere are better ways to do that so that you do not lose the reference\nto the application object :meth:`~flask.Flask.wsgi_app`).\n\nFurthermore this design makes it possible to use a factory function to\ncreate the application which is very helpful for unit testing and similar\nthings (:doc:`/patterns/appfactories`).\n\n"", ""What Flask is, What Flask is Not\n--------------------------------\n\nFlask will never have a database layer. It will not have a form library\nor anything else in that direction. Flask itself just bridges to Werkzeug\nto implement a proper WSGI application and to Jinja to handle templating.\nIt also binds to a few common standard library packages such as logging.\nEverything else is up for extensions.\n\nWhy is this the case? Because people have different preferences and\nrequirements and Flask could not meet those if it would force any of this\ninto the core. The majority of web applications will need a template\nengine in some sort. However not every application needs a SQL database.\n\nAs your codebase grows, you are free to make the design decisions appropriate\nfor your project. Flask will continue to provide a very simple glue layer to\nthe best that Python has to offer. You can implement advanced patterns in\nSQLAlchemy or another database tool, introduce non-relational data persistence\nas appropriate, and take advantage of framework-agnostic tools built for WSGI,\nthe Python web interface.\n\nThe idea of Flask is to build a good foundation for all applications.\nEverything else is up to you or extensions.\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/design.rst#codepoints:6201:9843"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:design.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-celery.rst-head0,dp-Flask-patterns-celery.rst,Flask 3.1.3 documentation: Application Factory,"[""Application Factory\n-------------------\n\nWhen using the Flask application factory pattern, call the ``celery_init_app`` function\ninside the factory. It sets ``app.extensions[\""celery\""]`` to the Celery app object, which\ncan be used to get the Celery app from the Flask app returned by the factory.\n\n.. code-block:: python\n\n def create_app() -> Flask:\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n app.config.from_prefixed_env()\n celery_init_app(app)\n return app\n\nTo use ``celery`` commands, Celery needs an app object, but that's no longer directly\navailable. Create a ``make_celery.py`` file that calls the Flask app factory and gets\nthe Celery app from the returned Flask app.\n\n.. code-block:: python\n\n from example import create_app\n\n flask_app = create_app()\n celery_app = flask_app.extensions[\""celery\""]\n\nPoint the ``celery`` command to this file.\n\n.. code-block:: text\n\n $ celery -A make_celery worker --loglevel INFO\n $ celery -A make_celery beat --loglevel INFO\n\n\nDefining Tasks\n--------------\n\nUsing ``@celery_app.task`` to decorate task functions requires access to the\n``celery_app`` object, which won't be available when using the factory pattern. It also\nmeans that the decorated tasks are tied to the specific Flask and Celery app instances,\nwhich could be an issue during testing if you change configuration for a test.\n\nInstead, use Celery's ``@shared_task`` decorator. This creates task objects that will\naccess whatever the \""current app\"" is, which is a similar concept to Flask's blueprints\nand app context. This is why we called ``celery_app.set_default()`` above.\n\nHere's an example task that adds two numbers together and returns the result.\n\n.. code-block:: python\n\n from celery import shared_task\n\n @shared_task(ignore_result=False)\n def add_together(a: int, b: int) -> int:\n return a + b\n\nEarlier, we configured Celery to ignore task results by default. Since we want to know\nthe return value of this task, we set ``ignore_result=False``. On the other hand, a task\nthat didn't need a result, such as sending an email, wouldn't set this.\n\n\nCalling Tasks\n-------------\n\nThe decorated function becomes a task object with methods to call it in the background.\nThe simplest way is to use the ``delay(*args, **kwargs)`` method. See Celery's docs for\nmore methods.\n\nA Celery worker must be running to run the task. Starting a worker is shown in the\nprevious sections.\n\n.. code-block:: python\n\n from flask import request\n\n @app.post(\""/add\"")\n def start_add() -> dict[str, object]:\n a = request.form.get(\""a\"", type=int)\n b = request.form.get(\""b\"", type=int)\n result = add_together.delay(a, b)\n return {\""result_id\"": result.id}\n\nThe route doesn't get the task's result immediately. That would defeat the purpose by\nblocking the response. Instead, we return the running task's result id, which we can use\nlater to get the result.\n\n\n""]","[""Background Tasks with Celery\n============================\n\nIf your application has a long running task, such as processing some uploaded data or\nsending email, you don't want to wait for it to finish during a request. Instead, use a\ntask queue to send the necessary data to another process that will run the task in the\nbackground while the request returns immediately.\n\n`Celery`_ is a powerful task queue that can be used for simple background tasks as well\nas complex multi-stage programs and schedules. This guide will show you how to configure\nCelery using Flask. Read Celery's `First Steps with Celery`_ guide to learn how to use\nCelery itself.\n\n.. _Celery: https://celery.readthedocs.io\n.. _First Steps with Celery: https://celery.readthedocs.io/en/latest/getting-started/first-steps-with-celery.html\n\nThe Flask repository contains `an example `_\nbased on the information on this page, which also shows how to use JavaScript to submit\ntasks and poll for progress and results.\n\n\nInstall\n-------\n\nInstall Celery from PyPI, for example using pip:\n\n.. code-block:: text\n\n $ pip install celery\n\n\nIntegrate Celery with Flask\n---------------------------\n\nYou can use Celery without any integration with Flask, but it's convenient to configure\nit through Flask's config, and to let tasks access the Flask application.\n\nCelery uses similar ideas to Flask, with a ``Celery`` app object that has configuration\nand registers tasks. While creating a Flask app, use the following code to create and\nconfigure a Celery app as well.\n\n.. code-block:: python\n\n from celery import Celery, Task\n\n def celery_init_app(app: Flask) -> Celery:\n class FlaskTask(Task):\n def __call__(self, *args: object, **kwargs: object) -> object:\n with app.app_context():\n return self.run(*args, **kwargs)\n\n celery_app = Celery(app.name, task_cls=FlaskTask)\n celery_app.config_from_object(app.config[\""CELERY\""])\n celery_app.set_default()\n app.extensions[\""celery\""] = celery_app\n return celery_app\n\nThis creates and returns a ``Celery`` app object. Celery `configuration`_ is taken from\nthe ``CELERY`` key in the Flask configuration. The Celery app is set as the default, so\nthat it is seen during each request. The ``Task`` subclass automatically runs task\nfunctions with a Flask app context active, so that services like your database\nconnections are available.\n\n.. _configuration: https://celery.readthedocs.io/en/stable/userguide/configuration.html\n\nHere's a basic ``example.py`` that configures Celery to use Redis for communication. We\nenable a result backend, but ignore results by default. This allows us to store results\nonly for tasks where we care about the result.\n\n.. code-block:: python\n\n from flask import Flask\n\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n celery_app = celery_init_app(app)\n\nPoint the ``celery worker`` command at this and it will find the ``celery_app`` object.\n\n.. code-block:: text\n\n $ celery -A example worker --loglevel INFO\n\nYou can also run the ``celery beat`` command to run tasks on a schedule. See Celery's\ndocs for more information about defining schedules.\n\n.. code-block:: text\n\n $ celery -A example beat --loglevel INFO\n\n\n"", ""Getting Results\n---------------\n\nTo fetch the result of the task we started above, we'll add another route that takes the\nresult id we returned before. We return whether the task is finished (ready), whether it\nfinished successfully, and what the return value (or error) was if it is finished.\n\n.. code-block:: python\n\n from celery.result import AsyncResult\n\n @app.get(\""/result/\"")\n def task_result(id: str) -> dict[str, object]:\n result = AsyncResult(id)\n return {\n \""ready\"": result.ready(),\n \""successful\"": result.successful(),\n \""value\"": result.result if result.ready() else None,\n }\n\nNow you can start the task using the first route, then poll for the result using the\nsecond route. This keeps the Flask request workers from being blocked waiting for tasks\nto finish.\n\nThe Flask repository contains `an example `_\nusing JavaScript to submit tasks and poll for progress and results.\n\n\nPassing Data to Tasks\n---------------------\n\nThe \""add\"" task above took two integers as arguments. To pass arguments to tasks, Celery\nhas to serialize them to a format that it can pass to other processes. Therefore,\npassing complex objects is not recommended. For example, it would be impossible to pass\na SQLAlchemy model object, since that object is probably not serializable and is tied to\nthe session that queried it.\n\nPass the minimal amount of data necessary to fetch or recreate any complex data within\nthe task. Consider a task that will run when the logged in user asks for an archive of\ntheir data. The Flask request knows the logged in user, and has the user object queried\nfrom the database. It got that by querying the database for a given id, so the task can\ndo the same thing. Pass the user's id rather than the user object.\n\n.. code-block:: python\n\n @shared_task\n def generate_user_archive(user_id: str) -> None:\n user = db.session.get(User, user_id)\n ...\n\n generate_user_archive.delay(current_user.id)\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/celery.rst#codepoints:3479:6618"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/celery.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-celery.rst-head1,dp-Flask-patterns-celery.rst,Flask 3.1.3 documentation: Background Tasks with Celery,"[""Background Tasks with Celery\n============================\n\nIf your application has a long running task, such as processing some uploaded data or\nsending email, you don't want to wait for it to finish during a request. Instead, use a\ntask queue to send the necessary data to another process that will run the task in the\nbackground while the request returns immediately.\n\n`Celery`_ is a powerful task queue that can be used for simple background tasks as well\nas complex multi-stage programs and schedules. This guide will show you how to configure\nCelery using Flask. Read Celery's `First Steps with Celery`_ guide to learn how to use\nCelery itself.\n\n.. _Celery: https://celery.readthedocs.io\n.. _First Steps with Celery: https://celery.readthedocs.io/en/latest/getting-started/first-steps-with-celery.html\n\nThe Flask repository contains `an example `_\nbased on the information on this page, which also shows how to use JavaScript to submit\ntasks and poll for progress and results.\n\n\nInstall\n-------\n\nInstall Celery from PyPI, for example using pip:\n\n.. code-block:: text\n\n $ pip install celery\n\n\nIntegrate Celery with Flask\n---------------------------\n\nYou can use Celery without any integration with Flask, but it's convenient to configure\nit through Flask's config, and to let tasks access the Flask application.\n\nCelery uses similar ideas to Flask, with a ``Celery`` app object that has configuration\nand registers tasks. While creating a Flask app, use the following code to create and\nconfigure a Celery app as well.\n\n.. code-block:: python\n\n from celery import Celery, Task\n\n def celery_init_app(app: Flask) -> Celery:\n class FlaskTask(Task):\n def __call__(self, *args: object, **kwargs: object) -> object:\n with app.app_context():\n return self.run(*args, **kwargs)\n\n celery_app = Celery(app.name, task_cls=FlaskTask)\n celery_app.config_from_object(app.config[\""CELERY\""])\n celery_app.set_default()\n app.extensions[\""celery\""] = celery_app\n return celery_app\n\nThis creates and returns a ``Celery`` app object. Celery `configuration`_ is taken from\nthe ``CELERY`` key in the Flask configuration. The Celery app is set as the default, so\nthat it is seen during each request. The ``Task`` subclass automatically runs task\nfunctions with a Flask app context active, so that services like your database\nconnections are available.\n\n.. _configuration: https://celery.readthedocs.io/en/stable/userguide/configuration.html\n\nHere's a basic ``example.py`` that configures Celery to use Redis for communication. We\nenable a result backend, but ignore results by default. This allows us to store results\nonly for tasks where we care about the result.\n\n.. code-block:: python\n\n from flask import Flask\n\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n celery_app = celery_init_app(app)\n\nPoint the ``celery worker`` command at this and it will find the ``celery_app`` object.\n\n.. code-block:: text\n\n $ celery -A example worker --loglevel INFO\n\nYou can also run the ``celery beat`` command to run tasks on a schedule. See Celery's\ndocs for more information about defining schedules.\n\n.. code-block:: text\n\n $ celery -A example beat --loglevel INFO\n\n\n""]","[""Application Factory\n-------------------\n\nWhen using the Flask application factory pattern, call the ``celery_init_app`` function\ninside the factory. It sets ``app.extensions[\""celery\""]`` to the Celery app object, which\ncan be used to get the Celery app from the Flask app returned by the factory.\n\n.. code-block:: python\n\n def create_app() -> Flask:\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n app.config.from_prefixed_env()\n celery_init_app(app)\n return app\n\nTo use ``celery`` commands, Celery needs an app object, but that's no longer directly\navailable. Create a ``make_celery.py`` file that calls the Flask app factory and gets\nthe Celery app from the returned Flask app.\n\n.. code-block:: python\n\n from example import create_app\n\n flask_app = create_app()\n celery_app = flask_app.extensions[\""celery\""]\n\nPoint the ``celery`` command to this file.\n\n.. code-block:: text\n\n $ celery -A make_celery worker --loglevel INFO\n $ celery -A make_celery beat --loglevel INFO\n\n\nDefining Tasks\n--------------\n\nUsing ``@celery_app.task`` to decorate task functions requires access to the\n``celery_app`` object, which won't be available when using the factory pattern. It also\nmeans that the decorated tasks are tied to the specific Flask and Celery app instances,\nwhich could be an issue during testing if you change configuration for a test.\n\nInstead, use Celery's ``@shared_task`` decorator. This creates task objects that will\naccess whatever the \""current app\"" is, which is a similar concept to Flask's blueprints\nand app context. This is why we called ``celery_app.set_default()`` above.\n\nHere's an example task that adds two numbers together and returns the result.\n\n.. code-block:: python\n\n from celery import shared_task\n\n @shared_task(ignore_result=False)\n def add_together(a: int, b: int) -> int:\n return a + b\n\nEarlier, we configured Celery to ignore task results by default. Since we want to know\nthe return value of this task, we set ``ignore_result=False``. On the other hand, a task\nthat didn't need a result, such as sending an email, wouldn't set this.\n\n\nCalling Tasks\n-------------\n\nThe decorated function becomes a task object with methods to call it in the background.\nThe simplest way is to use the ``delay(*args, **kwargs)`` method. See Celery's docs for\nmore methods.\n\nA Celery worker must be running to run the task. Starting a worker is shown in the\nprevious sections.\n\n.. code-block:: python\n\n from flask import request\n\n @app.post(\""/add\"")\n def start_add() -> dict[str, object]:\n a = request.form.get(\""a\"", type=int)\n b = request.form.get(\""b\"", type=int)\n result = add_together.delay(a, b)\n return {\""result_id\"": result.id}\n\nThe route doesn't get the task's result immediately. That would defeat the purpose by\nblocking the response. Instead, we return the running task's result id, which we can use\nlater to get the result.\n\n\n"", ""Getting Results\n---------------\n\nTo fetch the result of the task we started above, we'll add another route that takes the\nresult id we returned before. We return whether the task is finished (ready), whether it\nfinished successfully, and what the return value (or error) was if it is finished.\n\n.. code-block:: python\n\n from celery.result import AsyncResult\n\n @app.get(\""/result/\"")\n def task_result(id: str) -> dict[str, object]:\n result = AsyncResult(id)\n return {\n \""ready\"": result.ready(),\n \""successful\"": result.successful(),\n \""value\"": result.result if result.ready() else None,\n }\n\nNow you can start the task using the first route, then poll for the result using the\nsecond route. This keeps the Flask request workers from being blocked waiting for tasks\nto finish.\n\nThe Flask repository contains `an example `_\nusing JavaScript to submit tasks and poll for progress and results.\n\n\nPassing Data to Tasks\n---------------------\n\nThe \""add\"" task above took two integers as arguments. To pass arguments to tasks, Celery\nhas to serialize them to a format that it can pass to other processes. Therefore,\npassing complex objects is not recommended. For example, it would be impossible to pass\na SQLAlchemy model object, since that object is probably not serializable and is tied to\nthe session that queried it.\n\nPass the minimal amount of data necessary to fetch or recreate any complex data within\nthe task. Consider a task that will run when the logged in user asks for an archive of\ntheir data. The Flask request knows the logged in user, and has the user object queried\nfrom the database. It got that by querying the database for a given id, so the task can\ndo the same thing. Pass the user's id rather than the user object.\n\n.. code-block:: python\n\n @shared_task\n def generate_user_archive(user_id: str) -> None:\n user = db.session.get(User, user_id)\n ...\n\n generate_user_archive.delay(current_user.id)\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/celery.rst#codepoints:0:3479"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/celery.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-celery.rst-head2,dp-Flask-patterns-celery.rst,Flask 3.1.3 documentation: Calling Tasks,"[""Application Factory\n-------------------\n\nWhen using the Flask application factory pattern, call the ``celery_init_app`` function\ninside the factory. It sets ``app.extensions[\""celery\""]`` to the Celery app object, which\ncan be used to get the Celery app from the Flask app returned by the factory.\n\n.. code-block:: python\n\n def create_app() -> Flask:\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n app.config.from_prefixed_env()\n celery_init_app(app)\n return app\n\nTo use ``celery`` commands, Celery needs an app object, but that's no longer directly\navailable. Create a ``make_celery.py`` file that calls the Flask app factory and gets\nthe Celery app from the returned Flask app.\n\n.. code-block:: python\n\n from example import create_app\n\n flask_app = create_app()\n celery_app = flask_app.extensions[\""celery\""]\n\nPoint the ``celery`` command to this file.\n\n.. code-block:: text\n\n $ celery -A make_celery worker --loglevel INFO\n $ celery -A make_celery beat --loglevel INFO\n\n\nDefining Tasks\n--------------\n\nUsing ``@celery_app.task`` to decorate task functions requires access to the\n``celery_app`` object, which won't be available when using the factory pattern. It also\nmeans that the decorated tasks are tied to the specific Flask and Celery app instances,\nwhich could be an issue during testing if you change configuration for a test.\n\nInstead, use Celery's ``@shared_task`` decorator. This creates task objects that will\naccess whatever the \""current app\"" is, which is a similar concept to Flask's blueprints\nand app context. This is why we called ``celery_app.set_default()`` above.\n\nHere's an example task that adds two numbers together and returns the result.\n\n.. code-block:: python\n\n from celery import shared_task\n\n @shared_task(ignore_result=False)\n def add_together(a: int, b: int) -> int:\n return a + b\n\nEarlier, we configured Celery to ignore task results by default. Since we want to know\nthe return value of this task, we set ``ignore_result=False``. On the other hand, a task\nthat didn't need a result, such as sending an email, wouldn't set this.\n\n\nCalling Tasks\n-------------\n\nThe decorated function becomes a task object with methods to call it in the background.\nThe simplest way is to use the ``delay(*args, **kwargs)`` method. See Celery's docs for\nmore methods.\n\nA Celery worker must be running to run the task. Starting a worker is shown in the\nprevious sections.\n\n.. code-block:: python\n\n from flask import request\n\n @app.post(\""/add\"")\n def start_add() -> dict[str, object]:\n a = request.form.get(\""a\"", type=int)\n b = request.form.get(\""b\"", type=int)\n result = add_together.delay(a, b)\n return {\""result_id\"": result.id}\n\nThe route doesn't get the task's result immediately. That would defeat the purpose by\nblocking the response. Instead, we return the running task's result id, which we can use\nlater to get the result.\n\n\n""]","[""Background Tasks with Celery\n============================\n\nIf your application has a long running task, such as processing some uploaded data or\nsending email, you don't want to wait for it to finish during a request. Instead, use a\ntask queue to send the necessary data to another process that will run the task in the\nbackground while the request returns immediately.\n\n`Celery`_ is a powerful task queue that can be used for simple background tasks as well\nas complex multi-stage programs and schedules. This guide will show you how to configure\nCelery using Flask. Read Celery's `First Steps with Celery`_ guide to learn how to use\nCelery itself.\n\n.. _Celery: https://celery.readthedocs.io\n.. _First Steps with Celery: https://celery.readthedocs.io/en/latest/getting-started/first-steps-with-celery.html\n\nThe Flask repository contains `an example `_\nbased on the information on this page, which also shows how to use JavaScript to submit\ntasks and poll for progress and results.\n\n\nInstall\n-------\n\nInstall Celery from PyPI, for example using pip:\n\n.. code-block:: text\n\n $ pip install celery\n\n\nIntegrate Celery with Flask\n---------------------------\n\nYou can use Celery without any integration with Flask, but it's convenient to configure\nit through Flask's config, and to let tasks access the Flask application.\n\nCelery uses similar ideas to Flask, with a ``Celery`` app object that has configuration\nand registers tasks. While creating a Flask app, use the following code to create and\nconfigure a Celery app as well.\n\n.. code-block:: python\n\n from celery import Celery, Task\n\n def celery_init_app(app: Flask) -> Celery:\n class FlaskTask(Task):\n def __call__(self, *args: object, **kwargs: object) -> object:\n with app.app_context():\n return self.run(*args, **kwargs)\n\n celery_app = Celery(app.name, task_cls=FlaskTask)\n celery_app.config_from_object(app.config[\""CELERY\""])\n celery_app.set_default()\n app.extensions[\""celery\""] = celery_app\n return celery_app\n\nThis creates and returns a ``Celery`` app object. Celery `configuration`_ is taken from\nthe ``CELERY`` key in the Flask configuration. The Celery app is set as the default, so\nthat it is seen during each request. The ``Task`` subclass automatically runs task\nfunctions with a Flask app context active, so that services like your database\nconnections are available.\n\n.. _configuration: https://celery.readthedocs.io/en/stable/userguide/configuration.html\n\nHere's a basic ``example.py`` that configures Celery to use Redis for communication. We\nenable a result backend, but ignore results by default. This allows us to store results\nonly for tasks where we care about the result.\n\n.. code-block:: python\n\n from flask import Flask\n\n app = Flask(__name__)\n app.config.from_mapping(\n CELERY=dict(\n broker_url=\""redis://localhost\"",\n result_backend=\""redis://localhost\"",\n task_ignore_result=True,\n ),\n )\n celery_app = celery_init_app(app)\n\nPoint the ``celery worker`` command at this and it will find the ``celery_app`` object.\n\n.. code-block:: text\n\n $ celery -A example worker --loglevel INFO\n\nYou can also run the ``celery beat`` command to run tasks on a schedule. See Celery's\ndocs for more information about defining schedules.\n\n.. code-block:: text\n\n $ celery -A example beat --loglevel INFO\n\n\n"", ""Getting Results\n---------------\n\nTo fetch the result of the task we started above, we'll add another route that takes the\nresult id we returned before. We return whether the task is finished (ready), whether it\nfinished successfully, and what the return value (or error) was if it is finished.\n\n.. code-block:: python\n\n from celery.result import AsyncResult\n\n @app.get(\""/result/\"")\n def task_result(id: str) -> dict[str, object]:\n result = AsyncResult(id)\n return {\n \""ready\"": result.ready(),\n \""successful\"": result.successful(),\n \""value\"": result.result if result.ready() else None,\n }\n\nNow you can start the task using the first route, then poll for the result using the\nsecond route. This keeps the Flask request workers from being blocked waiting for tasks\nto finish.\n\nThe Flask repository contains `an example `_\nusing JavaScript to submit tasks and poll for progress and results.\n\n\nPassing Data to Tasks\n---------------------\n\nThe \""add\"" task above took two integers as arguments. To pass arguments to tasks, Celery\nhas to serialize them to a format that it can pass to other processes. Therefore,\npassing complex objects is not recommended. For example, it would be impossible to pass\na SQLAlchemy model object, since that object is probably not serializable and is tied to\nthe session that queried it.\n\nPass the minimal amount of data necessary to fetch or recreate any complex data within\nthe task. Consider a task that will run when the logged in user asks for an archive of\ntheir data. The Flask request knows the logged in user, and has the user object queried\nfrom the database. It got that by querying the database for a given id, so the task can\ndo the same thing. Pass the user's id rather than the user object.\n\n.. code-block:: python\n\n @shared_task\n def generate_user_archive(user_id: str) -> None:\n user = db.session.get(User, user_id)\n ...\n\n generate_user_archive.delay(current_user.id)\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/celery.rst#codepoints:3479:6618"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/celery.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-sqlalchemy.rst-head0,dp-Flask-patterns-sqlalchemy.rst,Flask 3.1.3 documentation: Manual Object Relational Mapping,"[""Manual Object Relational Mapping\n--------------------------------\n\nManual object relational mapping has a few upsides and a few downsides\nversus the declarative approach from above. The main difference is that\nyou define tables and classes separately and map them together. It's more\nflexible but a little more to type. In general it works like the\ndeclarative approach, so make sure to also split up your application into\nmultiple modules in a package.\n\nHere is an example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine, MetaData\n from sqlalchemy.orm import scoped_session, sessionmaker\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData()\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n def init_db():\n metadata.create_all(bind=engine)\n\nAs in the declarative approach, you need to close the session after\neach request or application context shutdown. Put this into your\napplication module::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example table and model (put this into :file:`models.py`)::\n\n from sqlalchemy import Table, Column, Integer, String\n from sqlalchemy.orm import mapper\n from yourapplication.database import metadata, db_session\n\n class User(object):\n query = db_session.query_property()\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\n users = Table('users', metadata,\n Column('id', Integer, primary_key=True),\n Column('name', String(50), unique=True),\n Column('email', String(120), unique=True)\n )\n mapper(User, users)\n\nQuerying and inserting works exactly the same as in the example above.\n\n\nSQL Abstraction Layer\n---------------------\n\nIf you just want to use the database system (and SQL) abstraction layer\nyou basically only need the engine::\n\n from sqlalchemy import create_engine, MetaData, Table\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData(bind=engine)\n\nThen you can either declare the tables in your code like in the examples\nabove, or automatically load them::\n\n from sqlalchemy import Table\n\n users = Table('users', metadata, autoload=True)\n\nTo insert data you can use the `insert` method. We have to get a\nconnection first so that we can use a transaction:\n\n>>> con = engine.connect()\n>>> con.execute(users.insert(), name='admin', email='admin@localhost')\n\nSQLAlchemy will automatically commit for us.\n\nTo query your database, you use the engine directly or use a connection:\n\n>>> users.select(users.c.id == 1).execute().first()\n(1, 'admin', 'admin@localhost')\n\nThese results are also dict-like tuples:\n\n>>> r = users.select(users.c.id == 1).execute().first()\n>>> r['name']\n'admin'\n\nYou can also pass strings of SQL statements to the\n:meth:`~sqlalchemy.engine.base.Connection.execute` method:\n\n>>> engine.execute('select * from users where id = :1', [1]).first()\n(1, 'admin', 'admin@localhost')\n\nFor more information about SQLAlchemy, head over to the\n`website `_.\n""]","[""SQLAlchemy in Flask\n===================\n\nMany people prefer `SQLAlchemy`_ for database access. In this case it's\nencouraged to use a package instead of a module for your flask application\nand drop the models into a separate module (:doc:`packages`). While that\nis not necessary, it makes a lot of sense.\n\nThere are four very common ways to use SQLAlchemy. I will outline each\nof them here:\n\nFlask-SQLAlchemy Extension\n--------------------------\n\nBecause SQLAlchemy is a common database abstraction layer and object\nrelational mapper that requires a little bit of configuration effort,\nthere is a Flask extension that handles that for you. This is recommended\nif you want to get started quickly.\n\nYou can download `Flask-SQLAlchemy`_ from `PyPI\n`_.\n\n.. _Flask-SQLAlchemy: https://flask-sqlalchemy.palletsprojects.com/\n\n\nDeclarative\n-----------\n\nThe declarative extension in SQLAlchemy is the most recent method of using\nSQLAlchemy. It allows you to define tables and models in one go, similar\nto how Django works. In addition to the following text I recommend the\nofficial documentation on the `declarative`_ extension.\n\nHere's the example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine\n from sqlalchemy.orm import scoped_session, sessionmaker, declarative_base\n\n engine = create_engine('sqlite:////tmp/test.db')\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n Base = declarative_base()\n Base.query = db_session.query_property()\n\n def init_db():\n # import all modules here that might define models so that\n # they will be registered properly on the metadata. Otherwise\n # you will have to import them first before calling init_db()\n import yourapplication.models\n Base.metadata.create_all(bind=engine)\n\nTo define your models, just subclass the `Base` class that was created by\nthe code above. If you are wondering why we don't have to care about\nthreads here (like we did in the SQLite3 example above with the\n:data:`~flask.g` object): that's because SQLAlchemy does that for us\nalready with the :class:`~sqlalchemy.orm.scoped_session`.\n\nTo use SQLAlchemy in a declarative way with your application, you just\nhave to put the following code into your application module. Flask will\nautomatically remove database sessions at the end of the request or\nwhen the application shuts down::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example model (put this into :file:`models.py`, e.g.)::\n\n from sqlalchemy import Column, Integer, String\n from yourapplication.database import Base\n\n class User(Base):\n __tablename__ = 'users'\n id = Column(Integer, primary_key=True)\n name = Column(String(50), unique=True)\n email = Column(String(120), unique=True)\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\nTo create the database you can use the `init_db` function:\n\n>>> from yourapplication.database import init_db\n>>> init_db()\n\nYou can insert entries into the database like this:\n\n>>> from yourapplication.database import db_session\n>>> from yourapplication.models import User\n>>> u = User('admin', 'admin@localhost')\n>>> db_session.add(u)\n>>> db_session.commit()\n\nQuerying is simple as well:\n\n>>> User.query.all()\n[]\n>>> User.query.filter(User.name == 'admin').first()\n\n\n.. _SQLAlchemy: https://www.sqlalchemy.org/\n.. _declarative: https://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/sqlalchemy.rst#codepoints:3892:7294"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/sqlalchemy.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-sqlalchemy.rst-head1,dp-Flask-patterns-sqlalchemy.rst,Flask 3.1.3 documentation: SQLAlchemy in Flask,"[""SQLAlchemy in Flask\n===================\n\nMany people prefer `SQLAlchemy`_ for database access. In this case it's\nencouraged to use a package instead of a module for your flask application\nand drop the models into a separate module (:doc:`packages`). While that\nis not necessary, it makes a lot of sense.\n\nThere are four very common ways to use SQLAlchemy. I will outline each\nof them here:\n\nFlask-SQLAlchemy Extension\n--------------------------\n\nBecause SQLAlchemy is a common database abstraction layer and object\nrelational mapper that requires a little bit of configuration effort,\nthere is a Flask extension that handles that for you. This is recommended\nif you want to get started quickly.\n\nYou can download `Flask-SQLAlchemy`_ from `PyPI\n`_.\n\n.. _Flask-SQLAlchemy: https://flask-sqlalchemy.palletsprojects.com/\n\n\nDeclarative\n-----------\n\nThe declarative extension in SQLAlchemy is the most recent method of using\nSQLAlchemy. It allows you to define tables and models in one go, similar\nto how Django works. In addition to the following text I recommend the\nofficial documentation on the `declarative`_ extension.\n\nHere's the example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine\n from sqlalchemy.orm import scoped_session, sessionmaker, declarative_base\n\n engine = create_engine('sqlite:////tmp/test.db')\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n Base = declarative_base()\n Base.query = db_session.query_property()\n\n def init_db():\n # import all modules here that might define models so that\n # they will be registered properly on the metadata. Otherwise\n # you will have to import them first before calling init_db()\n import yourapplication.models\n Base.metadata.create_all(bind=engine)\n\nTo define your models, just subclass the `Base` class that was created by\nthe code above. If you are wondering why we don't have to care about\nthreads here (like we did in the SQLite3 example above with the\n:data:`~flask.g` object): that's because SQLAlchemy does that for us\nalready with the :class:`~sqlalchemy.orm.scoped_session`.\n\nTo use SQLAlchemy in a declarative way with your application, you just\nhave to put the following code into your application module. Flask will\nautomatically remove database sessions at the end of the request or\nwhen the application shuts down::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example model (put this into :file:`models.py`, e.g.)::\n\n from sqlalchemy import Column, Integer, String\n from yourapplication.database import Base\n\n class User(Base):\n __tablename__ = 'users'\n id = Column(Integer, primary_key=True)\n name = Column(String(50), unique=True)\n email = Column(String(120), unique=True)\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\nTo create the database you can use the `init_db` function:\n\n>>> from yourapplication.database import init_db\n>>> init_db()\n\nYou can insert entries into the database like this:\n\n>>> from yourapplication.database import db_session\n>>> from yourapplication.models import User\n>>> u = User('admin', 'admin@localhost')\n>>> db_session.add(u)\n>>> db_session.commit()\n\nQuerying is simple as well:\n\n>>> User.query.all()\n[]\n>>> User.query.filter(User.name == 'admin').first()\n\n\n.. _SQLAlchemy: https://www.sqlalchemy.org/\n.. _declarative: https://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/\n\n""]","[""Manual Object Relational Mapping\n--------------------------------\n\nManual object relational mapping has a few upsides and a few downsides\nversus the declarative approach from above. The main difference is that\nyou define tables and classes separately and map them together. It's more\nflexible but a little more to type. In general it works like the\ndeclarative approach, so make sure to also split up your application into\nmultiple modules in a package.\n\nHere is an example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine, MetaData\n from sqlalchemy.orm import scoped_session, sessionmaker\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData()\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n def init_db():\n metadata.create_all(bind=engine)\n\nAs in the declarative approach, you need to close the session after\neach request or application context shutdown. Put this into your\napplication module::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example table and model (put this into :file:`models.py`)::\n\n from sqlalchemy import Table, Column, Integer, String\n from sqlalchemy.orm import mapper\n from yourapplication.database import metadata, db_session\n\n class User(object):\n query = db_session.query_property()\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\n users = Table('users', metadata,\n Column('id', Integer, primary_key=True),\n Column('name', String(50), unique=True),\n Column('email', String(120), unique=True)\n )\n mapper(User, users)\n\nQuerying and inserting works exactly the same as in the example above.\n\n\nSQL Abstraction Layer\n---------------------\n\nIf you just want to use the database system (and SQL) abstraction layer\nyou basically only need the engine::\n\n from sqlalchemy import create_engine, MetaData, Table\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData(bind=engine)\n\nThen you can either declare the tables in your code like in the examples\nabove, or automatically load them::\n\n from sqlalchemy import Table\n\n users = Table('users', metadata, autoload=True)\n\nTo insert data you can use the `insert` method. We have to get a\nconnection first so that we can use a transaction:\n\n>>> con = engine.connect()\n>>> con.execute(users.insert(), name='admin', email='admin@localhost')\n\nSQLAlchemy will automatically commit for us.\n\nTo query your database, you use the engine directly or use a connection:\n\n>>> users.select(users.c.id == 1).execute().first()\n(1, 'admin', 'admin@localhost')\n\nThese results are also dict-like tuples:\n\n>>> r = users.select(users.c.id == 1).execute().first()\n>>> r['name']\n'admin'\n\nYou can also pass strings of SQL statements to the\n:meth:`~sqlalchemy.engine.base.Connection.execute` method:\n\n>>> engine.execute('select * from users where id = :1', [1]).first()\n(1, 'admin', 'admin@localhost')\n\nFor more information about SQLAlchemy, head over to the\n`website `_.\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/sqlalchemy.rst#codepoints:0:3892"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/sqlalchemy.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-patterns-sqlalchemy.rst-head2,dp-Flask-patterns-sqlalchemy.rst,Flask 3.1.3 documentation: Flask-SQLAlchemy Extension,"[""SQLAlchemy in Flask\n===================\n\nMany people prefer `SQLAlchemy`_ for database access. In this case it's\nencouraged to use a package instead of a module for your flask application\nand drop the models into a separate module (:doc:`packages`). While that\nis not necessary, it makes a lot of sense.\n\nThere are four very common ways to use SQLAlchemy. I will outline each\nof them here:\n\nFlask-SQLAlchemy Extension\n--------------------------\n\nBecause SQLAlchemy is a common database abstraction layer and object\nrelational mapper that requires a little bit of configuration effort,\nthere is a Flask extension that handles that for you. This is recommended\nif you want to get started quickly.\n\nYou can download `Flask-SQLAlchemy`_ from `PyPI\n`_.\n\n.. _Flask-SQLAlchemy: https://flask-sqlalchemy.palletsprojects.com/\n\n\nDeclarative\n-----------\n\nThe declarative extension in SQLAlchemy is the most recent method of using\nSQLAlchemy. It allows you to define tables and models in one go, similar\nto how Django works. In addition to the following text I recommend the\nofficial documentation on the `declarative`_ extension.\n\nHere's the example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine\n from sqlalchemy.orm import scoped_session, sessionmaker, declarative_base\n\n engine = create_engine('sqlite:////tmp/test.db')\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n Base = declarative_base()\n Base.query = db_session.query_property()\n\n def init_db():\n # import all modules here that might define models so that\n # they will be registered properly on the metadata. Otherwise\n # you will have to import them first before calling init_db()\n import yourapplication.models\n Base.metadata.create_all(bind=engine)\n\nTo define your models, just subclass the `Base` class that was created by\nthe code above. If you are wondering why we don't have to care about\nthreads here (like we did in the SQLite3 example above with the\n:data:`~flask.g` object): that's because SQLAlchemy does that for us\nalready with the :class:`~sqlalchemy.orm.scoped_session`.\n\nTo use SQLAlchemy in a declarative way with your application, you just\nhave to put the following code into your application module. Flask will\nautomatically remove database sessions at the end of the request or\nwhen the application shuts down::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example model (put this into :file:`models.py`, e.g.)::\n\n from sqlalchemy import Column, Integer, String\n from yourapplication.database import Base\n\n class User(Base):\n __tablename__ = 'users'\n id = Column(Integer, primary_key=True)\n name = Column(String(50), unique=True)\n email = Column(String(120), unique=True)\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\nTo create the database you can use the `init_db` function:\n\n>>> from yourapplication.database import init_db\n>>> init_db()\n\nYou can insert entries into the database like this:\n\n>>> from yourapplication.database import db_session\n>>> from yourapplication.models import User\n>>> u = User('admin', 'admin@localhost')\n>>> db_session.add(u)\n>>> db_session.commit()\n\nQuerying is simple as well:\n\n>>> User.query.all()\n[]\n>>> User.query.filter(User.name == 'admin').first()\n\n\n.. _SQLAlchemy: https://www.sqlalchemy.org/\n.. _declarative: https://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/\n\n""]","[""Manual Object Relational Mapping\n--------------------------------\n\nManual object relational mapping has a few upsides and a few downsides\nversus the declarative approach from above. The main difference is that\nyou define tables and classes separately and map them together. It's more\nflexible but a little more to type. In general it works like the\ndeclarative approach, so make sure to also split up your application into\nmultiple modules in a package.\n\nHere is an example :file:`database.py` module for your application::\n\n from sqlalchemy import create_engine, MetaData\n from sqlalchemy.orm import scoped_session, sessionmaker\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData()\n db_session = scoped_session(sessionmaker(autocommit=False,\n autoflush=False,\n bind=engine))\n def init_db():\n metadata.create_all(bind=engine)\n\nAs in the declarative approach, you need to close the session after\neach request or application context shutdown. Put this into your\napplication module::\n\n from yourapplication.database import db_session\n\n @app.teardown_appcontext\n def shutdown_session(exception=None):\n db_session.remove()\n\nHere is an example table and model (put this into :file:`models.py`)::\n\n from sqlalchemy import Table, Column, Integer, String\n from sqlalchemy.orm import mapper\n from yourapplication.database import metadata, db_session\n\n class User(object):\n query = db_session.query_property()\n\n def __init__(self, name=None, email=None):\n self.name = name\n self.email = email\n\n def __repr__(self):\n return f''\n\n users = Table('users', metadata,\n Column('id', Integer, primary_key=True),\n Column('name', String(50), unique=True),\n Column('email', String(120), unique=True)\n )\n mapper(User, users)\n\nQuerying and inserting works exactly the same as in the example above.\n\n\nSQL Abstraction Layer\n---------------------\n\nIf you just want to use the database system (and SQL) abstraction layer\nyou basically only need the engine::\n\n from sqlalchemy import create_engine, MetaData, Table\n\n engine = create_engine('sqlite:////tmp/test.db')\n metadata = MetaData(bind=engine)\n\nThen you can either declare the tables in your code like in the examples\nabove, or automatically load them::\n\n from sqlalchemy import Table\n\n users = Table('users', metadata, autoload=True)\n\nTo insert data you can use the `insert` method. We have to get a\nconnection first so that we can use a transaction:\n\n>>> con = engine.connect()\n>>> con.execute(users.insert(), name='admin', email='admin@localhost')\n\nSQLAlchemy will automatically commit for us.\n\nTo query your database, you use the engine directly or use a connection:\n\n>>> users.select(users.c.id == 1).execute().first()\n(1, 'admin', 'admin@localhost')\n\nThese results are also dict-like tuples:\n\n>>> r = users.select(users.c.id == 1).execute().first()\n>>> r['name']\n'admin'\n\nYou can also pass strings of SQL statements to the\n:meth:`~sqlalchemy.engine.base.Connection.execute` method:\n\n>>> engine.execute('select * from users where id = :1', [1]).first()\n(1, 'admin', 'admin@localhost')\n\nFor more information about SQLAlchemy, head over to the\n`website `_.\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/patterns/sqlalchemy.rst#codepoints:0:3892"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:patterns/sqlalchemy.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-quickstart.rst-head0,dp-Flask-quickstart.rst,Flask 3.1.3 documentation: APIs with JSON,"[""About Responses\n---------------\n\nThe return value from a view function is automatically converted into\na response object for you. If the return value is a string it's\nconverted into a response object with the string as response body, a\n``200 OK`` status code and a :mimetype:`text/html` mimetype. If the\nreturn value is a dict or list, :func:`jsonify` is called to produce a\nresponse. The logic that Flask applies to converting return values into\nresponse objects is as follows:\n\n1. If a response object of the correct type is returned it's directly\n returned from the view.\n2. If it's a string, a response object is created with that data and\n the default parameters.\n3. If it's an iterator or generator returning strings or bytes, it is\n treated as a streaming response.\n4. If it's a dict or list, a response object is created using\n :func:`~flask.json.jsonify`.\n5. If a tuple is returned the items in the tuple can provide extra\n information. Such tuples have to be in the form\n ``(response, status)``, ``(response, headers)``, or\n ``(response, status, headers)``. The ``status`` value will override\n the status code and ``headers`` can be a list or dictionary of\n additional header values.\n6. If none of that works, Flask will assume the return value is a\n valid WSGI application and convert that into a response object.\n\nIf you want to get hold of the resulting response object inside the view\nyou can use the :func:`~flask.make_response` function.\n\nImagine you have a view like this::\n\n from flask import render_template\n\n @app.errorhandler(404)\n def not_found(error):\n return render_template('error.html'), 404\n\nYou just need to wrap the return expression with\n:func:`~flask.make_response` and get the response object to modify it, then\nreturn it::\n\n from flask import make_response\n\n @app.errorhandler(404)\n def not_found(error):\n resp = make_response(render_template('error.html'), 404)\n resp.headers['X-Something'] = 'A value'\n return resp\n\n\nAPIs with JSON\n``````````````\n\nA common response format when writing an API is JSON. It's easy to get\nstarted writing such an API with Flask. If you return a ``dict`` or\n``list`` from a view, it will be converted to a JSON response.\n\n.. code-block:: python\n\n @app.route(\""/me\"")\n def me_api():\n user = get_current_user()\n return {\n \""username\"": user.username,\n \""theme\"": user.theme,\n \""image\"": url_for(\""user_image\"", filename=user.image),\n }\n\n @app.route(\""/users\"")\n def users_api():\n users = get_all_users()\n return [user.to_json() for user in users]\n\nThis is a shortcut to passing the data to the\n:func:`~flask.json.jsonify` function, which will serialize any supported\nJSON data type. That means that all the data in the dict or list must be\nJSON serializable.\n\nFor complex types such as database models, you'll want to use a\nserialization library to convert the data to valid JSON types first.\nThere are many serialization libraries and Flask API extensions\nmaintained by the community that support more complex applications.\n\n\n.. _sessions:\n\n""]","[""Rendering Templates\n-------------------\n\nGenerating HTML from within Python is not fun, and actually pretty\ncumbersome because you have to do the HTML escaping on your own to keep\nthe application secure. Because of that Flask configures the `Jinja\n`_ template engine for you automatically.\n\nTemplates can be used to generate any type of text file. For web applications, you'll\nprimarily be generating HTML pages, but you can also generate markdown, plain text for\nemails, and anything else.\n\nFor a reference to HTML, CSS, and other web APIs, use the `MDN Web Docs`_.\n\n.. _MDN Web Docs: https://developer.mozilla.org/\n\nTo render a template you can use the :func:`~flask.render_template`\nmethod. All you have to do is provide the name of the template and the\nvariables you want to pass to the template engine as keyword arguments.\nHere's a simple example of how to render a template::\n\n from flask import render_template\n\n @app.route('/hello/')\n @app.route('/hello/')\n def hello(name=None):\n return render_template('hello.html', person=name)\n\nFlask will look for templates in the :file:`templates` folder. So if your\napplication is a module, this folder is next to that module, if it's a\npackage it's actually inside your package:\n\n**Case 1**: a module::\n\n /application.py\n /templates\n /hello.html\n\n**Case 2**: a package::\n\n /application\n /__init__.py\n /templates\n /hello.html\n\nFor templates you can use the full power of Jinja templates. Head over\nto the official `Jinja Template Documentation\n`_ for more information.\n\nHere is an example template:\n\n.. sourcecode:: html+jinja\n\n \n Hello from Flask\n {% if person %}\n

Hello {{ person }}!

\n {% else %}\n

Hello, World!

\n {% endif %}\n\nInside templates you also have access to the :data:`~flask.Flask.config`,\n:class:`~flask.request`, :class:`~flask.session` and :class:`~flask.g` [#]_ objects\nas well as the :func:`~flask.url_for` and :func:`~flask.get_flashed_messages` functions.\n\nTemplates are especially useful if inheritance is used. If you want to\nknow how that works, see :doc:`patterns/templateinheritance`. Basically\ntemplate inheritance makes it possible to keep certain elements on each\npage (like header, navigation and footer).\n\nAutomatic escaping is enabled, so if ``person`` contains HTML it will be escaped\nautomatically. If you can trust a variable and you know that it will be\nsafe HTML (for example because it came from a module that converts wiki\nmarkup to HTML) you can mark it as safe by using the\n:class:`~markupsafe.Markup` class or by using the ``|safe`` filter in the\ntemplate. Head over to the Jinja 2 documentation for more examples.\n\nHere is a basic introduction to how the :class:`~markupsafe.Markup` class works::\n\n >>> from markupsafe import Markup\n >>> Markup('Hello %s!') % 'hacker'\n Markup('Hello <blink>hacker</blink>!')\n >>> Markup.escape('hacker')\n Markup('<blink>hacker</blink>')\n >>> Markup('Marked up » HTML').striptags()\n 'Marked up » HTML'\n\n.. versionchanged:: 0.5\n\n Autoescaping is no longer enabled for all templates. The following\n extensions for templates trigger autoescaping: ``.html``, ``.htm``,\n ``.xml``, ``.xhtml``. Templates loaded from a string will have\n autoescaping disabled.\n\n.. [#] Unsure what that :class:`~flask.g` object is? It's something in which\n you can store information for your own needs. See the documentation\n for :class:`flask.g` and :doc:`patterns/sqlite3`.\n\n\n"", ""The Request Object\n``````````````````\n\nThe request object is documented in the API section and we will not cover\nit here in detail (see :class:`~flask.Request`). Here is a broad overview of\nsome of the most common operations. First of all you have to import it from\nthe ``flask`` module::\n\n from flask import request\n\nThe current request method is available by using the\n:attr:`~flask.Request.method` attribute. To access form data (data\ntransmitted in a ``POST`` or ``PUT`` request) you can use the\n:attr:`~flask.Request.form` attribute. Here is a full example of the two\nattributes mentioned above::\n\n @app.route('/login', methods=['POST', 'GET'])\n def login():\n error = None\n if request.method == 'POST':\n if valid_login(request.form['username'],\n request.form['password']):\n return log_the_user_in(request.form['username'])\n else:\n error = 'Invalid username/password'\n # the code below is executed if the request method\n # was GET or the credentials were invalid\n return render_template('login.html', error=error)\n\nWhat happens if the key does not exist in the ``form`` attribute? In that\ncase a special :exc:`KeyError` is raised. You can catch it like a\nstandard :exc:`KeyError` but if you don't do that, a HTTP 400 Bad Request\nerror page is shown instead. So for many situations you don't have to\ndeal with that problem.\n\nTo access parameters submitted in the URL (``?key=value``) you can use the\n:attr:`~flask.Request.args` attribute::\n\n searchword = request.args.get('key', '')\n\nWe recommend accessing URL parameters with `get` or by catching the\n:exc:`KeyError` because users might change the URL and presenting them a 400\nbad request page in that case is not user friendly.\n\nFor a full list of methods and attributes of the request object, head over\nto the :class:`~flask.Request` documentation.\n\n\nFile Uploads\n````````````\n\nYou can handle uploaded files with Flask easily. Just make sure not to\nforget to set the ``enctype=\""multipart/form-data\""`` attribute on your HTML\nform, otherwise the browser will not transmit your files at all.\n\nUploaded files are stored in memory or at a temporary location on the\nfilesystem. You can access those files by looking at the\n:attr:`~flask.request.files` attribute on the request object. Each\nuploaded file is stored in that dictionary. It behaves just like a\nstandard Python :class:`file` object, but it also has a\n:meth:`~werkzeug.datastructures.FileStorage.save` method that\nallows you to store that file on the filesystem of the server.\nHere is a simple example showing how that works::\n\n from flask import request\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n f = request.files['the_file']\n f.save('/var/www/uploads/uploaded_file.txt')\n ...\n\nIf you want to know how the file was named on the client before it was\nuploaded to your application, you can access the\n:attr:`~werkzeug.datastructures.FileStorage.filename` attribute.\nHowever please keep in mind that this value can be forged\nso never ever trust that value. If you want to use the filename\nof the client to store the file on the server, pass it through the\n:func:`~werkzeug.utils.secure_filename` function that\nWerkzeug provides for you::\n\n from werkzeug.utils import secure_filename\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n file = request.files['the_file']\n file.save(f\""/var/www/uploads/{secure_filename(file.filename)}\"")\n ...\n\nFor some better examples, see :doc:`patterns/fileuploads`.\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/quickstart.rst#codepoints:23928:27082"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:quickstart.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-quickstart.rst-head1,dp-Flask-quickstart.rst,Flask 3.1.3 documentation: Static Files,"[""HTTP Methods\n````````````\n\nWeb applications use different HTTP methods when accessing URLs. You should\nfamiliarize yourself with the HTTP methods as you work with Flask. By default,\na route only answers to ``GET`` requests. You can use the ``methods`` argument\nof the :meth:`~flask.Flask.route` decorator to handle different HTTP methods.\n::\n\n from flask import request\n\n @app.route('/login', methods=['GET', 'POST'])\n def login():\n if request.method == 'POST':\n return do_the_login()\n else:\n return show_the_login_form()\n\nThe example above keeps all methods for the route within one function,\nwhich can be useful if each part uses some common data.\n\nYou can also separate views for different methods into different\nfunctions. Flask provides a shortcut for decorating such routes with\n:meth:`~flask.Flask.get`, :meth:`~flask.Flask.post`, etc. for each\ncommon HTTP method.\n\n.. code-block:: python\n\n @app.get('/login')\n def login_get():\n return show_the_login_form()\n\n @app.post('/login')\n def login_post():\n return do_the_login()\n\nIf ``GET`` is present, Flask automatically adds support for the ``HEAD`` method\nand handles ``HEAD`` requests according to the `HTTP RFC`_. Likewise,\n``OPTIONS`` is automatically implemented for you.\n\n.. _HTTP RFC: https://www.ietf.org/rfc/rfc2068.txt\n\nStatic Files\n------------\n\nDynamic web applications also need static files. That's usually where\nthe CSS and JavaScript files are coming from. Ideally your web server is\nconfigured to serve them for you, but during development Flask can do that\nas well. Just create a folder called :file:`static` in your package or next to\nyour module and it will be available at ``/static`` on the application.\n\nTo generate URLs for static files, use the special ``'static'`` endpoint name::\n\n url_for('static', filename='style.css')\n\nThe file has to be stored on the filesystem as :file:`static/style.css`.\n\n""]","[""Quickstart\n==========\n\nEager to get started? This page gives a good introduction to Flask.\nFollow :doc:`installation` to set up a project and install Flask first.\n\n\nA Minimal Application\n---------------------\n\nA minimal Flask application looks something like this:\n\n.. code-block:: python\n\n from flask import Flask\n\n app = Flask(__name__)\n\n @app.route(\""/\"")\n def hello_world():\n return \""

Hello, World!

\""\n\nSo what did that code do?\n\n1. First we imported the :class:`~flask.Flask` class. An instance of\n this class will be our WSGI application.\n2. Next we create an instance of this class. The first argument is the\n name of the application's module or package. ``__name__`` is a\n convenient shortcut for this that is appropriate for most cases.\n This is needed so that Flask knows where to look for resources such\n as templates and static files.\n3. We then use the :meth:`~flask.Flask.route` decorator to tell Flask\n what URL should trigger our function.\n4. The function returns the message we want to display in the user's\n browser. The default content type is HTML, so HTML in the string\n will be rendered by the browser.\n\nSave it as :file:`hello.py` or something similar. Make sure to not call\nyour application :file:`flask.py` because this would conflict with Flask\nitself.\n\nTo run the application, use the ``flask`` command or\n``python -m flask``. You need to tell the Flask where your application\nis with the ``--app`` option.\n\n.. code-block:: text\n\n $ flask --app hello run\n * Serving Flask app 'hello'\n * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)\n\n.. admonition:: Application Discovery Behavior\n\n As a shortcut, if the file is named ``app.py`` or ``wsgi.py``, you\n don't have to use ``--app``. See :doc:`/cli` for more details.\n\nThis launches a very simple builtin server, which is good enough for\ntesting but probably not what you want to use in production. For\ndeployment options see :doc:`deploying/index`.\n\nNow head over to http://127.0.0.1:5000/, and you should see your hello\nworld greeting.\n\nIf another program is already using port 5000, you'll see\n``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the\nserver tries to start. See :ref:`address-already-in-use` for how to\nhandle that.\n\n.. _public-server:\n\n.. admonition:: Externally Visible Server\n\n If you run the server you will notice that the server is only accessible\n from your own computer, not from any other in the network. This is the\n default because in debugging mode a user of the application can execute\n arbitrary Python code on your computer.\n\n If you have the debugger disabled or trust the users on your network,\n you can make the server publicly available simply by adding\n ``--host=0.0.0.0`` to the command line::\n\n $ flask run --host=0.0.0.0\n\n This tells your operating system to listen on all public IPs.\n\n\n"", ""The Request Object\n``````````````````\n\nThe request object is documented in the API section and we will not cover\nit here in detail (see :class:`~flask.Request`). Here is a broad overview of\nsome of the most common operations. First of all you have to import it from\nthe ``flask`` module::\n\n from flask import request\n\nThe current request method is available by using the\n:attr:`~flask.Request.method` attribute. To access form data (data\ntransmitted in a ``POST`` or ``PUT`` request) you can use the\n:attr:`~flask.Request.form` attribute. Here is a full example of the two\nattributes mentioned above::\n\n @app.route('/login', methods=['POST', 'GET'])\n def login():\n error = None\n if request.method == 'POST':\n if valid_login(request.form['username'],\n request.form['password']):\n return log_the_user_in(request.form['username'])\n else:\n error = 'Invalid username/password'\n # the code below is executed if the request method\n # was GET or the credentials were invalid\n return render_template('login.html', error=error)\n\nWhat happens if the key does not exist in the ``form`` attribute? In that\ncase a special :exc:`KeyError` is raised. You can catch it like a\nstandard :exc:`KeyError` but if you don't do that, a HTTP 400 Bad Request\nerror page is shown instead. So for many situations you don't have to\ndeal with that problem.\n\nTo access parameters submitted in the URL (``?key=value``) you can use the\n:attr:`~flask.Request.args` attribute::\n\n searchword = request.args.get('key', '')\n\nWe recommend accessing URL parameters with `get` or by catching the\n:exc:`KeyError` because users might change the URL and presenting them a 400\nbad request page in that case is not user friendly.\n\nFor a full list of methods and attributes of the request object, head over\nto the :class:`~flask.Request` documentation.\n\n\nFile Uploads\n````````````\n\nYou can handle uploaded files with Flask easily. Just make sure not to\nforget to set the ``enctype=\""multipart/form-data\""`` attribute on your HTML\nform, otherwise the browser will not transmit your files at all.\n\nUploaded files are stored in memory or at a temporary location on the\nfilesystem. You can access those files by looking at the\n:attr:`~flask.request.files` attribute on the request object. Each\nuploaded file is stored in that dictionary. It behaves just like a\nstandard Python :class:`file` object, but it also has a\n:meth:`~werkzeug.datastructures.FileStorage.save` method that\nallows you to store that file on the filesystem of the server.\nHere is a simple example showing how that works::\n\n from flask import request\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n f = request.files['the_file']\n f.save('/var/www/uploads/uploaded_file.txt')\n ...\n\nIf you want to know how the file was named on the client before it was\nuploaded to your application, you can access the\n:attr:`~werkzeug.datastructures.FileStorage.filename` attribute.\nHowever please keep in mind that this value can be forged\nso never ever trust that value. If you want to use the filename\nof the client to store the file on the server, pass it through the\n:func:`~werkzeug.utils.secure_filename` function that\nWerkzeug provides for you::\n\n from werkzeug.utils import secure_filename\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n file = request.files['the_file']\n file.save(f\""/var/www/uploads/{secure_filename(file.filename)}\"")\n ...\n\nFor some better examples, see :doc:`patterns/fileuploads`.\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/quickstart.rst#codepoints:9395:11349"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:quickstart.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-quickstart.rst-head2,dp-Flask-quickstart.rst,Flask 3.1.3 documentation: The Request Object,"[""The Request Object\n``````````````````\n\nThe request object is documented in the API section and we will not cover\nit here in detail (see :class:`~flask.Request`). Here is a broad overview of\nsome of the most common operations. First of all you have to import it from\nthe ``flask`` module::\n\n from flask import request\n\nThe current request method is available by using the\n:attr:`~flask.Request.method` attribute. To access form data (data\ntransmitted in a ``POST`` or ``PUT`` request) you can use the\n:attr:`~flask.Request.form` attribute. Here is a full example of the two\nattributes mentioned above::\n\n @app.route('/login', methods=['POST', 'GET'])\n def login():\n error = None\n if request.method == 'POST':\n if valid_login(request.form['username'],\n request.form['password']):\n return log_the_user_in(request.form['username'])\n else:\n error = 'Invalid username/password'\n # the code below is executed if the request method\n # was GET or the credentials were invalid\n return render_template('login.html', error=error)\n\nWhat happens if the key does not exist in the ``form`` attribute? In that\ncase a special :exc:`KeyError` is raised. You can catch it like a\nstandard :exc:`KeyError` but if you don't do that, a HTTP 400 Bad Request\nerror page is shown instead. So for many situations you don't have to\ndeal with that problem.\n\nTo access parameters submitted in the URL (``?key=value``) you can use the\n:attr:`~flask.Request.args` attribute::\n\n searchword = request.args.get('key', '')\n\nWe recommend accessing URL parameters with `get` or by catching the\n:exc:`KeyError` because users might change the URL and presenting them a 400\nbad request page in that case is not user friendly.\n\nFor a full list of methods and attributes of the request object, head over\nto the :class:`~flask.Request` documentation.\n\n\nFile Uploads\n````````````\n\nYou can handle uploaded files with Flask easily. Just make sure not to\nforget to set the ``enctype=\""multipart/form-data\""`` attribute on your HTML\nform, otherwise the browser will not transmit your files at all.\n\nUploaded files are stored in memory or at a temporary location on the\nfilesystem. You can access those files by looking at the\n:attr:`~flask.request.files` attribute on the request object. Each\nuploaded file is stored in that dictionary. It behaves just like a\nstandard Python :class:`file` object, but it also has a\n:meth:`~werkzeug.datastructures.FileStorage.save` method that\nallows you to store that file on the filesystem of the server.\nHere is a simple example showing how that works::\n\n from flask import request\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n f = request.files['the_file']\n f.save('/var/www/uploads/uploaded_file.txt')\n ...\n\nIf you want to know how the file was named on the client before it was\nuploaded to your application, you can access the\n:attr:`~werkzeug.datastructures.FileStorage.filename` attribute.\nHowever please keep in mind that this value can be forged\nso never ever trust that value. If you want to use the filename\nof the client to store the file on the server, pass it through the\n:func:`~werkzeug.utils.secure_filename` function that\nWerkzeug provides for you::\n\n from werkzeug.utils import secure_filename\n\n @app.route('/upload', methods=['GET', 'POST'])\n def upload_file():\n if request.method == 'POST':\n file = request.files['the_file']\n file.save(f\""/var/www/uploads/{secure_filename(file.filename)}\"")\n ...\n\nFor some better examples, see :doc:`patterns/fileuploads`.\n\n""]","[""Rendering Templates\n-------------------\n\nGenerating HTML from within Python is not fun, and actually pretty\ncumbersome because you have to do the HTML escaping on your own to keep\nthe application secure. Because of that Flask configures the `Jinja\n`_ template engine for you automatically.\n\nTemplates can be used to generate any type of text file. For web applications, you'll\nprimarily be generating HTML pages, but you can also generate markdown, plain text for\nemails, and anything else.\n\nFor a reference to HTML, CSS, and other web APIs, use the `MDN Web Docs`_.\n\n.. _MDN Web Docs: https://developer.mozilla.org/\n\nTo render a template you can use the :func:`~flask.render_template`\nmethod. All you have to do is provide the name of the template and the\nvariables you want to pass to the template engine as keyword arguments.\nHere's a simple example of how to render a template::\n\n from flask import render_template\n\n @app.route('/hello/')\n @app.route('/hello/')\n def hello(name=None):\n return render_template('hello.html', person=name)\n\nFlask will look for templates in the :file:`templates` folder. So if your\napplication is a module, this folder is next to that module, if it's a\npackage it's actually inside your package:\n\n**Case 1**: a module::\n\n /application.py\n /templates\n /hello.html\n\n**Case 2**: a package::\n\n /application\n /__init__.py\n /templates\n /hello.html\n\nFor templates you can use the full power of Jinja templates. Head over\nto the official `Jinja Template Documentation\n`_ for more information.\n\nHere is an example template:\n\n.. sourcecode:: html+jinja\n\n \n Hello from Flask\n {% if person %}\n

Hello {{ person }}!

\n {% else %}\n

Hello, World!

\n {% endif %}\n\nInside templates you also have access to the :data:`~flask.Flask.config`,\n:class:`~flask.request`, :class:`~flask.session` and :class:`~flask.g` [#]_ objects\nas well as the :func:`~flask.url_for` and :func:`~flask.get_flashed_messages` functions.\n\nTemplates are especially useful if inheritance is used. If you want to\nknow how that works, see :doc:`patterns/templateinheritance`. Basically\ntemplate inheritance makes it possible to keep certain elements on each\npage (like header, navigation and footer).\n\nAutomatic escaping is enabled, so if ``person`` contains HTML it will be escaped\nautomatically. If you can trust a variable and you know that it will be\nsafe HTML (for example because it came from a module that converts wiki\nmarkup to HTML) you can mark it as safe by using the\n:class:`~markupsafe.Markup` class or by using the ``|safe`` filter in the\ntemplate. Head over to the Jinja 2 documentation for more examples.\n\nHere is a basic introduction to how the :class:`~markupsafe.Markup` class works::\n\n >>> from markupsafe import Markup\n >>> Markup('Hello %s!') % 'hacker'\n Markup('Hello <blink>hacker</blink>!')\n >>> Markup.escape('hacker')\n Markup('<blink>hacker</blink>')\n >>> Markup('Marked up » HTML').striptags()\n 'Marked up » HTML'\n\n.. versionchanged:: 0.5\n\n Autoescaping is no longer enabled for all templates. The following\n extensions for templates trigger autoescaping: ``.html``, ``.htm``,\n ``.xml``, ``.xhtml``. Templates loaded from a string will have\n autoescaping disabled.\n\n.. [#] Unsure what that :class:`~flask.g` object is? It's something in which\n you can store information for your own needs. See the documentation\n for :class:`flask.g` and :doc:`patterns/sqlite3`.\n\n\n"", ""Accessing Request Data\n----------------------\n\nFor web applications it's crucial to react to the data a client sends to\nthe server. In Flask this information is provided by the global\n:class:`~flask.request` object. If you have some experience with Python\nyou might be wondering how that object can be global and how Flask\nmanages to still be threadsafe. The answer is context locals:\n\n\n.. _context-locals:\n\nContext Locals\n``````````````\n\n.. admonition:: Insider Information\n\n If you want to understand how that works and how you can implement\n tests with context locals, read this section, otherwise just skip it.\n\nCertain objects in Flask are global objects, but not of the usual kind.\nThese objects are actually proxies to objects that are local to a specific\ncontext. What a mouthful. But that is actually quite easy to understand.\n\nImagine the context being the handling thread. A request comes in and the\nweb server decides to spawn a new thread (or something else, the\nunderlying object is capable of dealing with concurrency systems other\nthan threads). When Flask starts its internal request handling it\nfigures out that the current thread is the active context and binds the\ncurrent application and the WSGI environments to that context (thread).\nIt does that in an intelligent way so that one application can invoke another\napplication without breaking.\n\nSo what does this mean to you? Basically you can completely ignore that\nthis is the case unless you are doing something like unit testing. You\nwill notice that code which depends on a request object will suddenly break\nbecause there is no request object. The solution is creating a request\nobject yourself and binding it to the context. The easiest solution for\nunit testing is to use the :meth:`~flask.Flask.test_request_context`\ncontext manager. In combination with the ``with`` statement it will bind a\ntest request so that you can interact with it. Here is an example::\n\n from flask import request\n\n with app.test_request_context('/hello', method='POST'):\n # now you can do something with the request until the\n # end of the with block, such as basic assertions:\n assert request.path == '/hello'\n assert request.method == 'POST'\n\nThe other possibility is passing a whole WSGI environment to the\n:meth:`~flask.Flask.request_context` method::\n\n with app.request_context(environ):\n assert request.method == 'POST'\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/quickstart.rst#codepoints:17535:21275"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:quickstart.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-tutorial-database.rst-head0,dp-Flask-tutorial-database.rst,Flask 3.1.3 documentation: Register with the Application,"[""Create the Tables\n-----------------\n\nIn SQLite, data is stored in *tables* and *columns*. These need to be\ncreated before you can store and retrieve data. Flaskr will store users\nin the ``user`` table, and posts in the ``post`` table. Create a file\nwith the SQL commands needed to create empty tables:\n\n.. code-block:: sql\n :caption: ``flaskr/schema.sql``\n\n DROP TABLE IF EXISTS user;\n DROP TABLE IF EXISTS post;\n\n CREATE TABLE user (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n username TEXT UNIQUE NOT NULL,\n password TEXT NOT NULL\n );\n\n CREATE TABLE post (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n author_id INTEGER NOT NULL,\n created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n title TEXT NOT NULL,\n body TEXT NOT NULL,\n FOREIGN KEY (author_id) REFERENCES user (id)\n );\n\nAdd the Python functions that will run these SQL commands to the\n``db.py`` file:\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_db():\n db = get_db()\n\n with current_app.open_resource('schema.sql') as f:\n db.executescript(f.read().decode('utf8'))\n\n\n @click.command('init-db')\n def init_db_command():\n \""\""\""Clear the existing data and create new tables.\""\""\""\n init_db()\n click.echo('Initialized the database.')\n\n\n sqlite3.register_converter(\n \""timestamp\"", lambda v: datetime.fromisoformat(v.decode())\n )\n\n:meth:`open_resource() ` opens a file relative to\nthe ``flaskr`` package, which is useful since you won't necessarily know\nwhere that location is when deploying the application later. ``get_db``\nreturns a database connection, which is used to execute the commands\nread from the file.\n\n:func:`click.command` defines a command line command called ``init-db``\nthat calls the ``init_db`` function and shows a success message to the\nuser. You can read :doc:`/cli` to learn more about writing commands.\n\nThe call to :func:`sqlite3.register_converter` tells Python how to\ninterpret timestamp values in the database. We convert the value to a\n:class:`datetime.datetime`.\n\n\nRegister with the Application\n-----------------------------\n\nThe ``close_db`` and ``init_db_command`` functions need to be registered\nwith the application instance; otherwise, they won't be used by the\napplication. However, since you're using a factory function, that\ninstance isn't available when writing the functions. Instead, write a\nfunction that takes an application and does the registration.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_app(app):\n app.teardown_appcontext(close_db)\n app.cli.add_command(init_db_command)\n\n:meth:`app.teardown_appcontext() ` tells\nFlask to call that function when cleaning up after returning the\nresponse.\n\n:meth:`app.cli.add_command() ` adds a new\ncommand that can be called with the ``flask`` command.\n\nImport and call this function from the factory. Place the new code at\nthe end of the factory function before returning the app.\n\n.. code-block:: python\n :caption: ``flaskr/__init__.py``\n\n def create_app():\n app = ...\n # existing code omitted\n\n from . import db\n db.init_app(app)\n\n return app\n\n\n""]","["".. currentmodule:: flask\n\nDefine and Access the Database\n==============================\n\nThe application will use a `SQLite`_ database to store users and posts.\nPython comes with built-in support for SQLite in the :mod:`sqlite3`\nmodule.\n\nSQLite is convenient because it doesn't require setting up a separate\ndatabase server and is built-in to Python. However, if concurrent\nrequests try to write to the database at the same time, they will slow\ndown as each write happens sequentially. Small applications won't notice\nthis. Once you become big, you may want to switch to a different\ndatabase.\n\nThe tutorial doesn't go into detail about SQL. If you are not familiar\nwith it, the SQLite docs describe the `language`_.\n\n.. _SQLite: https://sqlite.org/about.html\n.. _language: https://sqlite.org/lang.html\n\n\nConnect to the Database\n-----------------------\n\nThe first thing to do when working with a SQLite database (and most\nother Python database libraries) is to create a connection to it. Any\nqueries and operations are performed using the connection, which is\nclosed after the work is finished.\n\nIn web applications this connection is typically tied to the request. It\nis created at some point when handling a request, and closed before the\nresponse is sent.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n import sqlite3\n from datetime import datetime\n\n import click\n from flask import current_app, g\n\n\n def get_db():\n if 'db' not in g:\n g.db = sqlite3.connect(\n current_app.config['DATABASE'],\n detect_types=sqlite3.PARSE_DECLTYPES\n )\n g.db.row_factory = sqlite3.Row\n\n return g.db\n\n\n def close_db(e=None):\n db = g.pop('db', None)\n\n if db is not None:\n db.close()\n\n:data:`g` is a special object that is unique for each request. It is\nused to store data that might be accessed by multiple functions during\nthe request. The connection is stored and reused instead of creating a\nnew connection if ``get_db`` is called a second time in the same\nrequest.\n\n:data:`current_app` is another special object that points to the Flask\napplication handling the request. Since you used an application factory,\nthere is no application object when writing the rest of your code.\n``get_db`` will be called when the application has been created and is\nhandling a request, so :data:`current_app` can be used.\n\n:func:`sqlite3.connect` establishes a connection to the file pointed at\nby the ``DATABASE`` configuration key. This file doesn't have to exist\nyet, and won't until you initialize the database later.\n\n:class:`sqlite3.Row` tells the connection to return rows that behave\nlike dicts. This allows accessing the columns by name.\n\n``close_db`` checks if a connection was created by checking if ``g.db``\nwas set. If the connection exists, it is closed. Further down you will\ntell your application about the ``close_db`` function in the application\nfactory so that it is called after each request.\n\n\n"", ""Initialize the Database File\n----------------------------\n\nNow that ``init-db`` has been registered with the app, it can be called\nusing the ``flask`` command, similar to the ``run`` command from the\nprevious page.\n\n.. note::\n\n If you're still running the server from the previous page, you can\n either stop the server, or run this command in a new terminal. If\n you use a new terminal, remember to change to your project directory\n and activate the env as described in :doc:`/installation`.\n\nRun the ``init-db`` command:\n\n.. code-block:: none\n\n $ flask --app flaskr init-db\n Initialized the database.\n\nThere will now be a ``flaskr.sqlite`` file in the ``instance`` folder in\nyour project.\n\nContinue to :doc:`views`.\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/tutorial/database.rst#codepoints:3011:6290"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:tutorial/database.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-tutorial-database.rst-head1,dp-Flask-tutorial-database.rst,Flask 3.1.3 documentation: Initialize the Database File,"[""Initialize the Database File\n----------------------------\n\nNow that ``init-db`` has been registered with the app, it can be called\nusing the ``flask`` command, similar to the ``run`` command from the\nprevious page.\n\n.. note::\n\n If you're still running the server from the previous page, you can\n either stop the server, or run this command in a new terminal. If\n you use a new terminal, remember to change to your project directory\n and activate the env as described in :doc:`/installation`.\n\nRun the ``init-db`` command:\n\n.. code-block:: none\n\n $ flask --app flaskr init-db\n Initialized the database.\n\nThere will now be a ``flaskr.sqlite`` file in the ``instance`` folder in\nyour project.\n\nContinue to :doc:`views`.\n""]","["".. currentmodule:: flask\n\nDefine and Access the Database\n==============================\n\nThe application will use a `SQLite`_ database to store users and posts.\nPython comes with built-in support for SQLite in the :mod:`sqlite3`\nmodule.\n\nSQLite is convenient because it doesn't require setting up a separate\ndatabase server and is built-in to Python. However, if concurrent\nrequests try to write to the database at the same time, they will slow\ndown as each write happens sequentially. Small applications won't notice\nthis. Once you become big, you may want to switch to a different\ndatabase.\n\nThe tutorial doesn't go into detail about SQL. If you are not familiar\nwith it, the SQLite docs describe the `language`_.\n\n.. _SQLite: https://sqlite.org/about.html\n.. _language: https://sqlite.org/lang.html\n\n\nConnect to the Database\n-----------------------\n\nThe first thing to do when working with a SQLite database (and most\nother Python database libraries) is to create a connection to it. Any\nqueries and operations are performed using the connection, which is\nclosed after the work is finished.\n\nIn web applications this connection is typically tied to the request. It\nis created at some point when handling a request, and closed before the\nresponse is sent.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n import sqlite3\n from datetime import datetime\n\n import click\n from flask import current_app, g\n\n\n def get_db():\n if 'db' not in g:\n g.db = sqlite3.connect(\n current_app.config['DATABASE'],\n detect_types=sqlite3.PARSE_DECLTYPES\n )\n g.db.row_factory = sqlite3.Row\n\n return g.db\n\n\n def close_db(e=None):\n db = g.pop('db', None)\n\n if db is not None:\n db.close()\n\n:data:`g` is a special object that is unique for each request. It is\nused to store data that might be accessed by multiple functions during\nthe request. The connection is stored and reused instead of creating a\nnew connection if ``get_db`` is called a second time in the same\nrequest.\n\n:data:`current_app` is another special object that points to the Flask\napplication handling the request. Since you used an application factory,\nthere is no application object when writing the rest of your code.\n``get_db`` will be called when the application has been created and is\nhandling a request, so :data:`current_app` can be used.\n\n:func:`sqlite3.connect` establishes a connection to the file pointed at\nby the ``DATABASE`` configuration key. This file doesn't have to exist\nyet, and won't until you initialize the database later.\n\n:class:`sqlite3.Row` tells the connection to return rows that behave\nlike dicts. This allows accessing the columns by name.\n\n``close_db`` checks if a connection was created by checking if ``g.db``\nwas set. If the connection exists, it is closed. Further down you will\ntell your application about the ``close_db`` function in the application\nfactory so that it is called after each request.\n\n\n"", ""Create the Tables\n-----------------\n\nIn SQLite, data is stored in *tables* and *columns*. These need to be\ncreated before you can store and retrieve data. Flaskr will store users\nin the ``user`` table, and posts in the ``post`` table. Create a file\nwith the SQL commands needed to create empty tables:\n\n.. code-block:: sql\n :caption: ``flaskr/schema.sql``\n\n DROP TABLE IF EXISTS user;\n DROP TABLE IF EXISTS post;\n\n CREATE TABLE user (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n username TEXT UNIQUE NOT NULL,\n password TEXT NOT NULL\n );\n\n CREATE TABLE post (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n author_id INTEGER NOT NULL,\n created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n title TEXT NOT NULL,\n body TEXT NOT NULL,\n FOREIGN KEY (author_id) REFERENCES user (id)\n );\n\nAdd the Python functions that will run these SQL commands to the\n``db.py`` file:\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_db():\n db = get_db()\n\n with current_app.open_resource('schema.sql') as f:\n db.executescript(f.read().decode('utf8'))\n\n\n @click.command('init-db')\n def init_db_command():\n \""\""\""Clear the existing data and create new tables.\""\""\""\n init_db()\n click.echo('Initialized the database.')\n\n\n sqlite3.register_converter(\n \""timestamp\"", lambda v: datetime.fromisoformat(v.decode())\n )\n\n:meth:`open_resource() ` opens a file relative to\nthe ``flaskr`` package, which is useful since you won't necessarily know\nwhere that location is when deploying the application later. ``get_db``\nreturns a database connection, which is used to execute the commands\nread from the file.\n\n:func:`click.command` defines a command line command called ``init-db``\nthat calls the ``init_db`` function and shows a success message to the\nuser. You can read :doc:`/cli` to learn more about writing commands.\n\nThe call to :func:`sqlite3.register_converter` tells Python how to\ninterpret timestamp values in the database. We convert the value to a\n:class:`datetime.datetime`.\n\n\nRegister with the Application\n-----------------------------\n\nThe ``close_db`` and ``init_db_command`` functions need to be registered\nwith the application instance; otherwise, they won't be used by the\napplication. However, since you're using a factory function, that\ninstance isn't available when writing the functions. Instead, write a\nfunction that takes an application and does the registration.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_app(app):\n app.teardown_appcontext(close_db)\n app.cli.add_command(init_db_command)\n\n:meth:`app.teardown_appcontext() ` tells\nFlask to call that function when cleaning up after returning the\nresponse.\n\n:meth:`app.cli.add_command() ` adds a new\ncommand that can be called with the ``flask`` command.\n\nImport and call this function from the factory. Place the new code at\nthe end of the factory function before returning the app.\n\n.. code-block:: python\n :caption: ``flaskr/__init__.py``\n\n def create_app():\n app = ...\n # existing code omitted\n\n from . import db\n db.init_app(app)\n\n return app\n\n\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/tutorial/database.rst#codepoints:6290:7025"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:tutorial/database.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-flask-3.1-tutorial-database.rst-head2,dp-Flask-tutorial-database.rst,Flask 3.1.3 documentation: Connect to the Database,"["".. currentmodule:: flask\n\nDefine and Access the Database\n==============================\n\nThe application will use a `SQLite`_ database to store users and posts.\nPython comes with built-in support for SQLite in the :mod:`sqlite3`\nmodule.\n\nSQLite is convenient because it doesn't require setting up a separate\ndatabase server and is built-in to Python. However, if concurrent\nrequests try to write to the database at the same time, they will slow\ndown as each write happens sequentially. Small applications won't notice\nthis. Once you become big, you may want to switch to a different\ndatabase.\n\nThe tutorial doesn't go into detail about SQL. If you are not familiar\nwith it, the SQLite docs describe the `language`_.\n\n.. _SQLite: https://sqlite.org/about.html\n.. _language: https://sqlite.org/lang.html\n\n\nConnect to the Database\n-----------------------\n\nThe first thing to do when working with a SQLite database (and most\nother Python database libraries) is to create a connection to it. Any\nqueries and operations are performed using the connection, which is\nclosed after the work is finished.\n\nIn web applications this connection is typically tied to the request. It\nis created at some point when handling a request, and closed before the\nresponse is sent.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n import sqlite3\n from datetime import datetime\n\n import click\n from flask import current_app, g\n\n\n def get_db():\n if 'db' not in g:\n g.db = sqlite3.connect(\n current_app.config['DATABASE'],\n detect_types=sqlite3.PARSE_DECLTYPES\n )\n g.db.row_factory = sqlite3.Row\n\n return g.db\n\n\n def close_db(e=None):\n db = g.pop('db', None)\n\n if db is not None:\n db.close()\n\n:data:`g` is a special object that is unique for each request. It is\nused to store data that might be accessed by multiple functions during\nthe request. The connection is stored and reused instead of creating a\nnew connection if ``get_db`` is called a second time in the same\nrequest.\n\n:data:`current_app` is another special object that points to the Flask\napplication handling the request. Since you used an application factory,\nthere is no application object when writing the rest of your code.\n``get_db`` will be called when the application has been created and is\nhandling a request, so :data:`current_app` can be used.\n\n:func:`sqlite3.connect` establishes a connection to the file pointed at\nby the ``DATABASE`` configuration key. This file doesn't have to exist\nyet, and won't until you initialize the database later.\n\n:class:`sqlite3.Row` tells the connection to return rows that behave\nlike dicts. This allows accessing the columns by name.\n\n``close_db`` checks if a connection was created by checking if ``g.db``\nwas set. If the connection exists, it is closed. Further down you will\ntell your application about the ``close_db`` function in the application\nfactory so that it is called after each request.\n\n\n""]","[""Create the Tables\n-----------------\n\nIn SQLite, data is stored in *tables* and *columns*. These need to be\ncreated before you can store and retrieve data. Flaskr will store users\nin the ``user`` table, and posts in the ``post`` table. Create a file\nwith the SQL commands needed to create empty tables:\n\n.. code-block:: sql\n :caption: ``flaskr/schema.sql``\n\n DROP TABLE IF EXISTS user;\n DROP TABLE IF EXISTS post;\n\n CREATE TABLE user (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n username TEXT UNIQUE NOT NULL,\n password TEXT NOT NULL\n );\n\n CREATE TABLE post (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n author_id INTEGER NOT NULL,\n created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n title TEXT NOT NULL,\n body TEXT NOT NULL,\n FOREIGN KEY (author_id) REFERENCES user (id)\n );\n\nAdd the Python functions that will run these SQL commands to the\n``db.py`` file:\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_db():\n db = get_db()\n\n with current_app.open_resource('schema.sql') as f:\n db.executescript(f.read().decode('utf8'))\n\n\n @click.command('init-db')\n def init_db_command():\n \""\""\""Clear the existing data and create new tables.\""\""\""\n init_db()\n click.echo('Initialized the database.')\n\n\n sqlite3.register_converter(\n \""timestamp\"", lambda v: datetime.fromisoformat(v.decode())\n )\n\n:meth:`open_resource() ` opens a file relative to\nthe ``flaskr`` package, which is useful since you won't necessarily know\nwhere that location is when deploying the application later. ``get_db``\nreturns a database connection, which is used to execute the commands\nread from the file.\n\n:func:`click.command` defines a command line command called ``init-db``\nthat calls the ``init_db`` function and shows a success message to the\nuser. You can read :doc:`/cli` to learn more about writing commands.\n\nThe call to :func:`sqlite3.register_converter` tells Python how to\ninterpret timestamp values in the database. We convert the value to a\n:class:`datetime.datetime`.\n\n\nRegister with the Application\n-----------------------------\n\nThe ``close_db`` and ``init_db_command`` functions need to be registered\nwith the application instance; otherwise, they won't be used by the\napplication. However, since you're using a factory function, that\ninstance isn't available when writing the functions. Instead, write a\nfunction that takes an application and does the registration.\n\n.. code-block:: python\n :caption: ``flaskr/db.py``\n\n def init_app(app):\n app.teardown_appcontext(close_db)\n app.cli.add_command(init_db_command)\n\n:meth:`app.teardown_appcontext() ` tells\nFlask to call that function when cleaning up after returning the\nresponse.\n\n:meth:`app.cli.add_command() ` adds a new\ncommand that can be called with the ``flask`` command.\n\nImport and call this function from the factory. Place the new code at\nthe end of the factory function before returning the app.\n\n.. code-block:: python\n :caption: ``flaskr/__init__.py``\n\n def create_app():\n app = ...\n # existing code omitted\n\n from . import db\n db.init_app(app)\n\n return app\n\n\n"", ""Initialize the Database File\n----------------------------\n\nNow that ``init-db`` has been registered with the app, it can be called\nusing the ``flask`` command, similar to the ``run`` command from the\nprevious page.\n\n.. note::\n\n If you're still running the server from the previous page, you can\n either stop the server, or run this command in a new terminal. If\n you use a new terminal, remember to change to your project directory\n and activate the env as described in :doc:`/installation`.\n\nRun the ``init-db`` command:\n\n.. code-block:: none\n\n $ flask --app flaskr init-db\n Initialized the database.\n\nThere will now be a ``flaskr.sqlite`` file in the ``instance`` folder in\nyour project.\n\nContinue to :doc:`views`.\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""flask-3.1.3/docs/tutorial/database.rst#codepoints:0:3011"", ""revision"": ""3.1.3+sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"", ""source_id"": ""flask-3.1:tutorial/database.rst"", ""uri"": ""https://files.pythonhosted.org/packages/26/00/35d85dcce6c57fdc871f3867d465d780f302a175ea360f62533f12b27e2b/flask-3.1.3.tar.gz""}]" dp-rt-jinja-3.1-switching.rst-head0,dp-Jinja-switching.rst,Jinja 3.1.6 documentation: Filter Arguments,"[""Switching From Other Template Engines\n=====================================\n\nThis is a brief guide on some of the differences between Jinja syntax\nand other template languages. See :doc:`/templates` for a comprehensive\nguide to Jinja syntax and features.\n\n\nDjango\n------\n\nIf you have previously worked with Django templates, you should find\nJinja very familiar. Many of the syntax elements look and work the same.\nHowever, Jinja provides some more syntax elements, and some work a bit\ndifferently.\n\nThis section covers the template changes. The API, including extension\nsupport, is fundamentally different so it won't be covered here.\n\nDjango supports using Jinja as its template engine, see\nhttps://docs.djangoproject.com/en/stable/topics/templates/#support-for-template-engines.\n\n\nMethod Calls\n~~~~~~~~~~~~\n\nIn Django, methods are called implicitly, without parentheses.\n\n.. code-block:: django\n\n {% for page in user.get_created_pages %}\n ...\n {% endfor %}\n\nIn Jinja, using parentheses is required for calls, like in Python. This\nallows you to pass variables to the method, which is not possible\nin Django. This syntax is also used for calling macros.\n\n.. code-block:: jinja\n\n {% for page in user.get_created_pages() %}\n ...\n {% endfor %}\n\n\nFilter Arguments\n~~~~~~~~~~~~~~~~\n\nIn Django, one literal value can be passed to a filter after a colon.\n\n.. code-block:: django\n\n {{ items|join:\"", \"" }}\n\nIn Jinja, filters can take any number of positional and keyword\narguments in parentheses, like function calls. Arguments can also be\nvariables instead of literal values.\n\n.. code-block:: jinja\n\n {{ items|join(\"", \"") }}\n\n\nTests\n~~~~~\n\nIn addition to filters, Jinja also has \""tests\"" used with the ``is``\noperator. This operator is not the same as the Python operator.\n\n.. code-block:: jinja\n\n {% if user.user_id is odd %}\n {{ user.username|e }} is odd\n {% else %}\n hmm. {{ user.username|e }} looks pretty normal\n {% endif %}\n\nLoops\n~~~~~\n\nIn Django, the special variable for the loop context is called\n``forloop``, and the ``empty`` is used for no loop items.\n\n.. code-block:: django\n\n {% for item in items %}\n {{ forloop.counter }}. {{ item }}\n {% empty %}\n No items!\n {% endfor %}\n\nIn Jinja, the special variable for the loop context is called ``loop``,\nand the ``else`` block is used for no loop items.\n\n.. code-block:: jinja\n\n {% for item in items %}\n {{ loop.index }}. {{ item }}\n {% else %}\n No items!\n {% endfor %}\n\n\nCycle\n~~~~~\n\nIn Django, the ``{% cycle %}`` can be used in a for loop to alternate\nbetween values per loop.\n\n.. code-block:: django\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nIn Jinja, the ``loop`` context has a ``cycle`` method.\n\n.. code-block:: jinja\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nA cycler can also be assigned to a variable and used outside or across\nloops with the ``cycle()`` global function.\n\n\n""]","[""Mako\n----\n\nYou can configure Jinja to look more like Mako:\n\n.. code-block:: python\n\n env = Environment(\n block_start_string=\""<%\"",\n block_end_string=\""%>\"",\n variable_start_string=\""${\"",\n variable_end_string=\""}\"",\n comment_start_string=\""<%doc>\"",\n commend_end_string=\""\"",\n line_statement_prefix=\""%\"",\n line_comment_prefix=\""##\"",\n )\n\nWith an environment configured like that, Jinja should be able to\ninterpret a small subset of Mako templates without any changes.\n\nJinja does not support embedded Python code, so you would have to move\nthat out of the template. You could either process the data with the\nsame code before rendering, or add a global function or filter to the\nJinja environment.\n\nThe syntax for defs (which are called macros in Jinja) and template\ninheritance is different too.\n\nThe following Mako template:\n\n.. code-block:: mako\n\n <%inherit file=\""layout.html\"" />\n <%def name=\""title()\"">Page Title\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n\nLooks like this in Jinja with the above configuration:\n\n.. code-block:: jinja\n\n <% extends \""layout.html\"" %>\n <% block title %>Page Title<% endblock %>\n <% block body %>\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n <% endblock %>\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/switching.rst#codepoints:0:3069"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:switching.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-jinja-3.1-switching.rst-head1,dp-Jinja-switching.rst,Jinja 3.1.6 documentation: Method Calls,"[""Switching From Other Template Engines\n=====================================\n\nThis is a brief guide on some of the differences between Jinja syntax\nand other template languages. See :doc:`/templates` for a comprehensive\nguide to Jinja syntax and features.\n\n\nDjango\n------\n\nIf you have previously worked with Django templates, you should find\nJinja very familiar. Many of the syntax elements look and work the same.\nHowever, Jinja provides some more syntax elements, and some work a bit\ndifferently.\n\nThis section covers the template changes. The API, including extension\nsupport, is fundamentally different so it won't be covered here.\n\nDjango supports using Jinja as its template engine, see\nhttps://docs.djangoproject.com/en/stable/topics/templates/#support-for-template-engines.\n\n\nMethod Calls\n~~~~~~~~~~~~\n\nIn Django, methods are called implicitly, without parentheses.\n\n.. code-block:: django\n\n {% for page in user.get_created_pages %}\n ...\n {% endfor %}\n\nIn Jinja, using parentheses is required for calls, like in Python. This\nallows you to pass variables to the method, which is not possible\nin Django. This syntax is also used for calling macros.\n\n.. code-block:: jinja\n\n {% for page in user.get_created_pages() %}\n ...\n {% endfor %}\n\n\nFilter Arguments\n~~~~~~~~~~~~~~~~\n\nIn Django, one literal value can be passed to a filter after a colon.\n\n.. code-block:: django\n\n {{ items|join:\"", \"" }}\n\nIn Jinja, filters can take any number of positional and keyword\narguments in parentheses, like function calls. Arguments can also be\nvariables instead of literal values.\n\n.. code-block:: jinja\n\n {{ items|join(\"", \"") }}\n\n\nTests\n~~~~~\n\nIn addition to filters, Jinja also has \""tests\"" used with the ``is``\noperator. This operator is not the same as the Python operator.\n\n.. code-block:: jinja\n\n {% if user.user_id is odd %}\n {{ user.username|e }} is odd\n {% else %}\n hmm. {{ user.username|e }} looks pretty normal\n {% endif %}\n\nLoops\n~~~~~\n\nIn Django, the special variable for the loop context is called\n``forloop``, and the ``empty`` is used for no loop items.\n\n.. code-block:: django\n\n {% for item in items %}\n {{ forloop.counter }}. {{ item }}\n {% empty %}\n No items!\n {% endfor %}\n\nIn Jinja, the special variable for the loop context is called ``loop``,\nand the ``else`` block is used for no loop items.\n\n.. code-block:: jinja\n\n {% for item in items %}\n {{ loop.index }}. {{ item }}\n {% else %}\n No items!\n {% endfor %}\n\n\nCycle\n~~~~~\n\nIn Django, the ``{% cycle %}`` can be used in a for loop to alternate\nbetween values per loop.\n\n.. code-block:: django\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nIn Jinja, the ``loop`` context has a ``cycle`` method.\n\n.. code-block:: jinja\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nA cycler can also be assigned to a variable and used outside or across\nloops with the ``cycle()`` global function.\n\n\n""]","[""Mako\n----\n\nYou can configure Jinja to look more like Mako:\n\n.. code-block:: python\n\n env = Environment(\n block_start_string=\""<%\"",\n block_end_string=\""%>\"",\n variable_start_string=\""${\"",\n variable_end_string=\""}\"",\n comment_start_string=\""<%doc>\"",\n commend_end_string=\""\"",\n line_statement_prefix=\""%\"",\n line_comment_prefix=\""##\"",\n )\n\nWith an environment configured like that, Jinja should be able to\ninterpret a small subset of Mako templates without any changes.\n\nJinja does not support embedded Python code, so you would have to move\nthat out of the template. You could either process the data with the\nsame code before rendering, or add a global function or filter to the\nJinja environment.\n\nThe syntax for defs (which are called macros in Jinja) and template\ninheritance is different too.\n\nThe following Mako template:\n\n.. code-block:: mako\n\n <%inherit file=\""layout.html\"" />\n <%def name=\""title()\"">Page Title\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n\nLooks like this in Jinja with the above configuration:\n\n.. code-block:: jinja\n\n <% extends \""layout.html\"" %>\n <% block title %>Page Title<% endblock %>\n <% block body %>\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n <% endblock %>\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/switching.rst#codepoints:0:3069"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:switching.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-jinja-3.1-switching.rst-head2,dp-Jinja-switching.rst,Jinja 3.1.6 documentation: Switching From Other Template Engines,"[""Switching From Other Template Engines\n=====================================\n\nThis is a brief guide on some of the differences between Jinja syntax\nand other template languages. See :doc:`/templates` for a comprehensive\nguide to Jinja syntax and features.\n\n\nDjango\n------\n\nIf you have previously worked with Django templates, you should find\nJinja very familiar. Many of the syntax elements look and work the same.\nHowever, Jinja provides some more syntax elements, and some work a bit\ndifferently.\n\nThis section covers the template changes. The API, including extension\nsupport, is fundamentally different so it won't be covered here.\n\nDjango supports using Jinja as its template engine, see\nhttps://docs.djangoproject.com/en/stable/topics/templates/#support-for-template-engines.\n\n\nMethod Calls\n~~~~~~~~~~~~\n\nIn Django, methods are called implicitly, without parentheses.\n\n.. code-block:: django\n\n {% for page in user.get_created_pages %}\n ...\n {% endfor %}\n\nIn Jinja, using parentheses is required for calls, like in Python. This\nallows you to pass variables to the method, which is not possible\nin Django. This syntax is also used for calling macros.\n\n.. code-block:: jinja\n\n {% for page in user.get_created_pages() %}\n ...\n {% endfor %}\n\n\nFilter Arguments\n~~~~~~~~~~~~~~~~\n\nIn Django, one literal value can be passed to a filter after a colon.\n\n.. code-block:: django\n\n {{ items|join:\"", \"" }}\n\nIn Jinja, filters can take any number of positional and keyword\narguments in parentheses, like function calls. Arguments can also be\nvariables instead of literal values.\n\n.. code-block:: jinja\n\n {{ items|join(\"", \"") }}\n\n\nTests\n~~~~~\n\nIn addition to filters, Jinja also has \""tests\"" used with the ``is``\noperator. This operator is not the same as the Python operator.\n\n.. code-block:: jinja\n\n {% if user.user_id is odd %}\n {{ user.username|e }} is odd\n {% else %}\n hmm. {{ user.username|e }} looks pretty normal\n {% endif %}\n\nLoops\n~~~~~\n\nIn Django, the special variable for the loop context is called\n``forloop``, and the ``empty`` is used for no loop items.\n\n.. code-block:: django\n\n {% for item in items %}\n {{ forloop.counter }}. {{ item }}\n {% empty %}\n No items!\n {% endfor %}\n\nIn Jinja, the special variable for the loop context is called ``loop``,\nand the ``else`` block is used for no loop items.\n\n.. code-block:: jinja\n\n {% for item in items %}\n {{ loop.index }}. {{ item }}\n {% else %}\n No items!\n {% endfor %}\n\n\nCycle\n~~~~~\n\nIn Django, the ``{% cycle %}`` can be used in a for loop to alternate\nbetween values per loop.\n\n.. code-block:: django\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nIn Jinja, the ``loop`` context has a ``cycle`` method.\n\n.. code-block:: jinja\n\n {% for user in users %}\n
  • {{ user }}
  • \n {% endfor %}\n\nA cycler can also be assigned to a variable and used outside or across\nloops with the ``cycle()`` global function.\n\n\n""]","[""Mako\n----\n\nYou can configure Jinja to look more like Mako:\n\n.. code-block:: python\n\n env = Environment(\n block_start_string=\""<%\"",\n block_end_string=\""%>\"",\n variable_start_string=\""${\"",\n variable_end_string=\""}\"",\n comment_start_string=\""<%doc>\"",\n commend_end_string=\""\"",\n line_statement_prefix=\""%\"",\n line_comment_prefix=\""##\"",\n )\n\nWith an environment configured like that, Jinja should be able to\ninterpret a small subset of Mako templates without any changes.\n\nJinja does not support embedded Python code, so you would have to move\nthat out of the template. You could either process the data with the\nsame code before rendering, or add a global function or filter to the\nJinja environment.\n\nThe syntax for defs (which are called macros in Jinja) and template\ninheritance is different too.\n\nThe following Mako template:\n\n.. code-block:: mako\n\n <%inherit file=\""layout.html\"" />\n <%def name=\""title()\"">Page Title\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n\nLooks like this in Jinja with the above configuration:\n\n.. code-block:: jinja\n\n <% extends \""layout.html\"" %>\n <% block title %>Page Title<% endblock %>\n <% block body %>\n
      \n % for item in list:\n
    • ${item}
    • \n % endfor\n
    \n <% endblock %>\n""]",answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/switching.rst#codepoints:0:3069"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:switching.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-jinja-3.1-tricks.rst-head0,dp-Jinja-tricks.rst,Jinja 3.1.6 documentation: Null-Default Fallback,"[""Tips and Tricks\n===============\n\n.. highlight:: html+jinja\n\nThis part of the documentation shows some tips and tricks for Jinja\ntemplates.\n\n\n.. _null-default-fallback:\n\nNull-Default Fallback\n---------------------\n\nJinja supports dynamic inheritance and does not distinguish between parent\nand child template as long as no `extends` tag is visited. While this leads\nto the surprising behavior that everything before the first `extends` tag\nincluding whitespace is printed out instead of being ignored, it can be used\nfor a neat trick.\n\nUsually child templates extend from one template that adds a basic HTML\nskeleton. However it's possible to put the `extends` tag into an `if` tag to\nonly extend from the layout template if the `standalone` variable evaluates\nto false, which it does by default if it's not defined. Additionally a very\nbasic skeleton is added to the file so that if it's indeed rendered with\n`standalone` set to `True` a very basic HTML skeleton is added::\n\n {% if not standalone %}{% extends 'default.html' %}{% endif -%}\n \n {% block title %}The Page Title{% endblock %}\n \n {% block body %}\n

    This is the page body.

    \n {% endblock %}\n\n\nAlternating Rows\n----------------\n\nIf you want to have different styles for each row of a table or\nlist you can use the `cycle` method on the `loop` object::\n\n
      \n {% for row in rows %}\n
    • {{ row }}
    • \n {% endfor %}\n
    \n\n`cycle` can take an unlimited number of strings. Each time this\ntag is encountered the next item from the list is rendered.\n\n\nHighlighting Active Menu Items\n------------------------------\n\nOften you want to have a navigation bar with an active navigation\nitem. This is really simple to achieve. Because assignments outside\nof `block`\\s in child templates are global and executed before the layout\ntemplate is evaluated it's possible to define the active menu item in the\nchild template::\n\n {% extends \""layout.html\"" %}\n {% set active_page = \""index\"" %}\n\nThe layout template can then access `active_page`. Additionally it makes\nsense to define a default for that variable::\n\n {% set navigation_bar = [\n ('/', 'index', 'Index'),\n ('/downloads/', 'downloads', 'Downloads'),\n ('/about/', 'about', 'About')\n ] -%}\n {% set active_page = active_page|default('index') -%}\n ...\n
      \n {% for href, id, caption in navigation_bar %}\n \n {{ caption|e }}\n {% endfor %}\n
    \n ...\n\n.. _accessing-the-parent-loop:\n\nAccessing the parent Loop\n-------------------------\n\nThe special `loop` variable always points to the innermost loop. If it's\ndesired to have access to an outer loop it's possible to alias it::\n\n \n {% for row in table %}\n \n {% set rowloop = loop %}\n {% for cell in row %}\n \n {% endfor %}\n \n {% endfor %}\n
    {{ cell }}
    \n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/tricks.rst#codepoints:0:3168"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:tricks.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-jinja-3.1-tricks.rst-head1,dp-Jinja-tricks.rst,Jinja 3.1.6 documentation: Tips and Tricks,"[""Tips and Tricks\n===============\n\n.. highlight:: html+jinja\n\nThis part of the documentation shows some tips and tricks for Jinja\ntemplates.\n\n\n.. _null-default-fallback:\n\nNull-Default Fallback\n---------------------\n\nJinja supports dynamic inheritance and does not distinguish between parent\nand child template as long as no `extends` tag is visited. While this leads\nto the surprising behavior that everything before the first `extends` tag\nincluding whitespace is printed out instead of being ignored, it can be used\nfor a neat trick.\n\nUsually child templates extend from one template that adds a basic HTML\nskeleton. However it's possible to put the `extends` tag into an `if` tag to\nonly extend from the layout template if the `standalone` variable evaluates\nto false, which it does by default if it's not defined. Additionally a very\nbasic skeleton is added to the file so that if it's indeed rendered with\n`standalone` set to `True` a very basic HTML skeleton is added::\n\n {% if not standalone %}{% extends 'default.html' %}{% endif -%}\n \n {% block title %}The Page Title{% endblock %}\n \n {% block body %}\n

    This is the page body.

    \n {% endblock %}\n\n\nAlternating Rows\n----------------\n\nIf you want to have different styles for each row of a table or\nlist you can use the `cycle` method on the `loop` object::\n\n
      \n {% for row in rows %}\n
    • {{ row }}
    • \n {% endfor %}\n
    \n\n`cycle` can take an unlimited number of strings. Each time this\ntag is encountered the next item from the list is rendered.\n\n\nHighlighting Active Menu Items\n------------------------------\n\nOften you want to have a navigation bar with an active navigation\nitem. This is really simple to achieve. Because assignments outside\nof `block`\\s in child templates are global and executed before the layout\ntemplate is evaluated it's possible to define the active menu item in the\nchild template::\n\n {% extends \""layout.html\"" %}\n {% set active_page = \""index\"" %}\n\nThe layout template can then access `active_page`. Additionally it makes\nsense to define a default for that variable::\n\n {% set navigation_bar = [\n ('/', 'index', 'Index'),\n ('/downloads/', 'downloads', 'Downloads'),\n ('/about/', 'about', 'About')\n ] -%}\n {% set active_page = active_page|default('index') -%}\n ...\n
      \n {% for href, id, caption in navigation_bar %}\n \n {{ caption|e }}\n {% endfor %}\n
    \n ...\n\n.. _accessing-the-parent-loop:\n\nAccessing the parent Loop\n-------------------------\n\nThe special `loop` variable always points to the innermost loop. If it's\ndesired to have access to an outer loop it's possible to alias it::\n\n \n {% for row in table %}\n \n {% set rowloop = loop %}\n {% for cell in row %}\n \n {% endfor %}\n \n {% endfor %}\n
    {{ cell }}
    \n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/tricks.rst#codepoints:0:3168"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:tricks.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-jinja-3.1-tricks.rst-head2,dp-Jinja-tricks.rst,Jinja 3.1.6 documentation: Accessing the parent Loop,"[""Tips and Tricks\n===============\n\n.. highlight:: html+jinja\n\nThis part of the documentation shows some tips and tricks for Jinja\ntemplates.\n\n\n.. _null-default-fallback:\n\nNull-Default Fallback\n---------------------\n\nJinja supports dynamic inheritance and does not distinguish between parent\nand child template as long as no `extends` tag is visited. While this leads\nto the surprising behavior that everything before the first `extends` tag\nincluding whitespace is printed out instead of being ignored, it can be used\nfor a neat trick.\n\nUsually child templates extend from one template that adds a basic HTML\nskeleton. However it's possible to put the `extends` tag into an `if` tag to\nonly extend from the layout template if the `standalone` variable evaluates\nto false, which it does by default if it's not defined. Additionally a very\nbasic skeleton is added to the file so that if it's indeed rendered with\n`standalone` set to `True` a very basic HTML skeleton is added::\n\n {% if not standalone %}{% extends 'default.html' %}{% endif -%}\n \n {% block title %}The Page Title{% endblock %}\n \n {% block body %}\n

    This is the page body.

    \n {% endblock %}\n\n\nAlternating Rows\n----------------\n\nIf you want to have different styles for each row of a table or\nlist you can use the `cycle` method on the `loop` object::\n\n
      \n {% for row in rows %}\n
    • {{ row }}
    • \n {% endfor %}\n
    \n\n`cycle` can take an unlimited number of strings. Each time this\ntag is encountered the next item from the list is rendered.\n\n\nHighlighting Active Menu Items\n------------------------------\n\nOften you want to have a navigation bar with an active navigation\nitem. This is really simple to achieve. Because assignments outside\nof `block`\\s in child templates are global and executed before the layout\ntemplate is evaluated it's possible to define the active menu item in the\nchild template::\n\n {% extends \""layout.html\"" %}\n {% set active_page = \""index\"" %}\n\nThe layout template can then access `active_page`. Additionally it makes\nsense to define a default for that variable::\n\n {% set navigation_bar = [\n ('/', 'index', 'Index'),\n ('/downloads/', 'downloads', 'Downloads'),\n ('/about/', 'about', 'About')\n ] -%}\n {% set active_page = active_page|default('index') -%}\n ...\n
      \n {% for href, id, caption in navigation_bar %}\n \n {{ caption|e }}\n {% endfor %}\n
    \n ...\n\n.. _accessing-the-parent-loop:\n\nAccessing the parent Loop\n-------------------------\n\nThe special `loop` variable always points to the innermost loop. If it's\ndesired to have access to an outer loop it's possible to alias it::\n\n \n {% for row in table %}\n \n {% set rowloop = loop %}\n {% for cell in row %}\n \n {% endfor %}\n \n {% endfor %}\n
    {{ cell }}
    \n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""jinja2-3.1.6/docs/tricks.rst#codepoints:0:3168"", ""revision"": ""3.1.6+sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"", ""source_id"": ""jinja-3.1:tricks.rst"", ""uri"": ""https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz""}]" dp-rt-cpython-3.13-c-api-float.rst-head0,dp-Python-c-api-float.rst,Python 3.13.0 documentation: Pack functions,"[""Pack functions\n^^^^^^^^^^^^^^\n\nThe pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if you want the bytes string in little-endian\nformat (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you\nwant big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`\nconstant can be used to use the native endian: it is equal to ``1`` on big\nendian processor, or ``0`` on little endian processor.\n\nReturn value: ``0`` if all is OK, ``-1`` if error (and an exception is set,\nmost likely :exc:`OverflowError`).\n\nThere are two problems on non-IEEE platforms:\n\n* What this does is undefined if *x* is a NaN or infinity.\n* ``-0.0`` and ``+0.0`` produce the same bytes string.\n\n.. c:function:: int PyFloat_Pack2(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary16 half-precision format.\n\n.. c:function:: int PyFloat_Pack4(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary32 single precision format.\n\n.. c:function:: int PyFloat_Pack8(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary64 double precision format.\n\n\nUnpack functions\n^^^^^^^^^^^^^^^^\n\nThe unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if the bytes string is in little-endian format\n(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian\n(exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can be used to\nuse the native endian: it is equal to ``1`` on big endian processor, or ``0``\non little endian processor.\n\nReturn value: The unpacked double. On error, this is ``-1.0`` and\n:c:func:`PyErr_Occurred` is true (and an exception is set, most likely\n:exc:`OverflowError`).\n\nNote that on a non-IEEE platform this will refuse to unpack a bytes string that\nrepresents a NaN or infinity.\n\n.. c:function:: double PyFloat_Unpack2(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary16 half-precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack4(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary32 single precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack8(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary64 double precision format as a C double.\n""]","["".. highlight:: c\n\n.. _floatobjects:\n\nFloating-Point Objects\n======================\n\n.. index:: pair: object; floating-point\n\n\n.. c:type:: PyFloatObject\n\n This subtype of :c:type:`PyObject` represents a Python floating-point object.\n\n\n.. c:var:: PyTypeObject PyFloat_Type\n\n This instance of :c:type:`PyTypeObject` represents the Python floating-point\n type. This is the same object as :class:`float` in the Python layer.\n\n\n.. c:function:: int PyFloat_Check(PyObject *p)\n\n Return true if its argument is a :c:type:`PyFloatObject` or a subtype of\n :c:type:`PyFloatObject`. This function always succeeds.\n\n\n.. c:function:: int PyFloat_CheckExact(PyObject *p)\n\n Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype of\n :c:type:`PyFloatObject`. This function always succeeds.\n\n\n.. c:function:: PyObject* PyFloat_FromString(PyObject *str)\n\n Create a :c:type:`PyFloatObject` object based on the string value in *str*, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyFloat_FromDouble(double v)\n\n Create a :c:type:`PyFloatObject` object from *v*, or ``NULL`` on failure.\n\n\n.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)\n\n Return a C :c:expr:`double` representation of the contents of *pyfloat*. If\n *pyfloat* is not a Python floating-point object but has a :meth:`~object.__float__`\n method, this method will first be called to convert *pyfloat* into a float.\n If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.\n This method returns ``-1.0`` upon failure, so one should call\n :c:func:`PyErr_Occurred` to check for errors.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n\n.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)\n\n Return a C :c:expr:`double` representation of the contents of *pyfloat*, but\n without error checking.\n\n\n.. c:function:: PyObject* PyFloat_GetInfo(void)\n\n Return a structseq instance which contains information about the\n precision, minimum and maximum values of a float. It's a thin wrapper\n around the header file :file:`float.h`.\n\n\n.. c:function:: double PyFloat_GetMax()\n\n Return the maximum representable finite float *DBL_MAX* as C :c:expr:`double`.\n\n\n.. c:function:: double PyFloat_GetMin()\n\n Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.\n\n\nPack and Unpack functions\n-------------------------\n\nThe pack and unpack functions provide an efficient platform-independent way to\nstore floating-point values as byte strings. The Pack routines produce a bytes\nstring from a C :c:expr:`double`, and the Unpack routines produce a C\n:c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies the\nnumber of bytes in the bytes string.\n\nOn platforms that appear to use IEEE 754 formats these functions work by\ncopying bits. On other platforms, the 2-byte format is identical to the IEEE\n754 binary16 half-precision format, the 4-byte format (32-bit) is identical to\nthe IEEE 754 binary32 single precision format, and the 8-byte format to the\nIEEE 754 binary64 double precision format, although the packing of INFs and\nNaNs (if such things exist on the platform) isn't handled correctly, and\nattempting to unpack a bytes string containing an IEEE INF or NaN will raise an\nexception.\n\nOn non-IEEE platforms with more precision, or larger dynamic range, than IEEE\n754 supports, not all values can be packed; on non-IEEE platforms with less\nprecision, or smaller dynamic range, not all values can be unpacked. What\nhappens in such cases is partly accidental (alas).\n\n.. versionadded:: 3.11\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/float.rst#codepoints:3608:5923"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/float.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-float.rst-head1,dp-Python-c-api-float.rst,Python 3.13.0 documentation: Unpack functions,"[""Pack functions\n^^^^^^^^^^^^^^\n\nThe pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if you want the bytes string in little-endian\nformat (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you\nwant big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`\nconstant can be used to use the native endian: it is equal to ``1`` on big\nendian processor, or ``0`` on little endian processor.\n\nReturn value: ``0`` if all is OK, ``-1`` if error (and an exception is set,\nmost likely :exc:`OverflowError`).\n\nThere are two problems on non-IEEE platforms:\n\n* What this does is undefined if *x* is a NaN or infinity.\n* ``-0.0`` and ``+0.0`` produce the same bytes string.\n\n.. c:function:: int PyFloat_Pack2(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary16 half-precision format.\n\n.. c:function:: int PyFloat_Pack4(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary32 single precision format.\n\n.. c:function:: int PyFloat_Pack8(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary64 double precision format.\n\n\nUnpack functions\n^^^^^^^^^^^^^^^^\n\nThe unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if the bytes string is in little-endian format\n(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian\n(exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can be used to\nuse the native endian: it is equal to ``1`` on big endian processor, or ``0``\non little endian processor.\n\nReturn value: The unpacked double. On error, this is ``-1.0`` and\n:c:func:`PyErr_Occurred` is true (and an exception is set, most likely\n:exc:`OverflowError`).\n\nNote that on a non-IEEE platform this will refuse to unpack a bytes string that\nrepresents a NaN or infinity.\n\n.. c:function:: double PyFloat_Unpack2(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary16 half-precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack4(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary32 single precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack8(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary64 double precision format as a C double.\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/float.rst#codepoints:3608:5923"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/float.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-float.rst-head2,dp-Python-c-api-float.rst,Python 3.13.0 documentation: Pack and Unpack functions,"["".. highlight:: c\n\n.. _floatobjects:\n\nFloating-Point Objects\n======================\n\n.. index:: pair: object; floating-point\n\n\n.. c:type:: PyFloatObject\n\n This subtype of :c:type:`PyObject` represents a Python floating-point object.\n\n\n.. c:var:: PyTypeObject PyFloat_Type\n\n This instance of :c:type:`PyTypeObject` represents the Python floating-point\n type. This is the same object as :class:`float` in the Python layer.\n\n\n.. c:function:: int PyFloat_Check(PyObject *p)\n\n Return true if its argument is a :c:type:`PyFloatObject` or a subtype of\n :c:type:`PyFloatObject`. This function always succeeds.\n\n\n.. c:function:: int PyFloat_CheckExact(PyObject *p)\n\n Return true if its argument is a :c:type:`PyFloatObject`, but not a subtype of\n :c:type:`PyFloatObject`. This function always succeeds.\n\n\n.. c:function:: PyObject* PyFloat_FromString(PyObject *str)\n\n Create a :c:type:`PyFloatObject` object based on the string value in *str*, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyFloat_FromDouble(double v)\n\n Create a :c:type:`PyFloatObject` object from *v*, or ``NULL`` on failure.\n\n\n.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)\n\n Return a C :c:expr:`double` representation of the contents of *pyfloat*. If\n *pyfloat* is not a Python floating-point object but has a :meth:`~object.__float__`\n method, this method will first be called to convert *pyfloat* into a float.\n If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.\n This method returns ``-1.0`` upon failure, so one should call\n :c:func:`PyErr_Occurred` to check for errors.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n\n.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)\n\n Return a C :c:expr:`double` representation of the contents of *pyfloat*, but\n without error checking.\n\n\n.. c:function:: PyObject* PyFloat_GetInfo(void)\n\n Return a structseq instance which contains information about the\n precision, minimum and maximum values of a float. It's a thin wrapper\n around the header file :file:`float.h`.\n\n\n.. c:function:: double PyFloat_GetMax()\n\n Return the maximum representable finite float *DBL_MAX* as C :c:expr:`double`.\n\n\n.. c:function:: double PyFloat_GetMin()\n\n Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.\n\n\nPack and Unpack functions\n-------------------------\n\nThe pack and unpack functions provide an efficient platform-independent way to\nstore floating-point values as byte strings. The Pack routines produce a bytes\nstring from a C :c:expr:`double`, and the Unpack routines produce a C\n:c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies the\nnumber of bytes in the bytes string.\n\nOn platforms that appear to use IEEE 754 formats these functions work by\ncopying bits. On other platforms, the 2-byte format is identical to the IEEE\n754 binary16 half-precision format, the 4-byte format (32-bit) is identical to\nthe IEEE 754 binary32 single precision format, and the 8-byte format to the\nIEEE 754 binary64 double precision format, although the packing of INFs and\nNaNs (if such things exist on the platform) isn't handled correctly, and\nattempting to unpack a bytes string containing an IEEE INF or NaN will raise an\nexception.\n\nOn non-IEEE platforms with more precision, or larger dynamic range, than IEEE\n754 supports, not all values can be packed; on non-IEEE platforms with less\nprecision, or smaller dynamic range, not all values can be unpacked. What\nhappens in such cases is partly accidental (alas).\n\n.. versionadded:: 3.11\n\n""]","[""Pack functions\n^^^^^^^^^^^^^^\n\nThe pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if you want the bytes string in little-endian\nformat (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you\nwant big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`\nconstant can be used to use the native endian: it is equal to ``1`` on big\nendian processor, or ``0`` on little endian processor.\n\nReturn value: ``0`` if all is OK, ``-1`` if error (and an exception is set,\nmost likely :exc:`OverflowError`).\n\nThere are two problems on non-IEEE platforms:\n\n* What this does is undefined if *x* is a NaN or infinity.\n* ``-0.0`` and ``+0.0`` produce the same bytes string.\n\n.. c:function:: int PyFloat_Pack2(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary16 half-precision format.\n\n.. c:function:: int PyFloat_Pack4(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary32 single precision format.\n\n.. c:function:: int PyFloat_Pack8(double x, unsigned char *p, int le)\n\n Pack a C double as the IEEE 754 binary64 double precision format.\n\n\nUnpack functions\n^^^^^^^^^^^^^^^^\n\nThe unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an\n:c:expr:`int` argument, non-zero if the bytes string is in little-endian format\n(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian\n(exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can be used to\nuse the native endian: it is equal to ``1`` on big endian processor, or ``0``\non little endian processor.\n\nReturn value: The unpacked double. On error, this is ``-1.0`` and\n:c:func:`PyErr_Occurred` is true (and an exception is set, most likely\n:exc:`OverflowError`).\n\nNote that on a non-IEEE platform this will refuse to unpack a bytes string that\nrepresents a NaN or infinity.\n\n.. c:function:: double PyFloat_Unpack2(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary16 half-precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack4(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary32 single precision format as a C double.\n\n.. c:function:: double PyFloat_Unpack8(const unsigned char *p, int le)\n\n Unpack the IEEE 754 binary64 double precision format as a C double.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/float.rst#codepoints:0:3608"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/float.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-gen.rst-head0,dp-Python-c-api-gen.rst,Python 3.13.0 documentation: Generator Objects,"["".. highlight:: c\n\n.. _gen-objects:\n\nGenerator Objects\n-----------------\n\nGenerator objects are what Python uses to implement generator iterators. They\nare normally created by iterating over a function that yields values, rather\nthan explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.\n\n\n.. c:type:: PyGenObject\n\n The C structure used for generator objects.\n\n\n.. c:var:: PyTypeObject PyGen_Type\n\n The type object corresponding to generator objects.\n\n\n.. c:function:: int PyGen_Check(PyObject *ob)\n\n Return true if *ob* is a generator object; *ob* must not be ``NULL``. This\n function always succeeds.\n\n\n.. c:function:: int PyGen_CheckExact(PyObject *ob)\n\n Return true if *ob*'s type is :c:type:`PyGen_Type`; *ob* must not be\n ``NULL``. This function always succeeds.\n\n\n.. c:function:: PyObject* PyGen_New(PyFrameObject *frame)\n\n Create and return a new generator object based on the *frame* object.\n A reference to *frame* is stolen by this function. The argument must not be\n ``NULL``.\n\n.. c:function:: PyObject* PyGen_NewWithQualName(PyFrameObject *frame, PyObject *name, PyObject *qualname)\n\n Create and return a new generator object based on the *frame* object,\n with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.\n A reference to *frame* is stolen by this function. The *frame* argument\n must not be ``NULL``.\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/gen.rst#codepoints:0:1383"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/gen.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-long.rst-head0,dp-Python-c-api-long.rst,Python 3.13.0 documentation: Integer Objects,"[""Integer Objects\n---------------\n\n.. index:: pair: object; long integer\n pair: object; integer\n\nAll integers are implemented as \""long\"" integer objects of arbitrary size.\n\nOn error, most ``PyLong_As*`` APIs return ``(return type)-1`` which cannot be\ndistinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n.. c:type:: PyLongObject\n\n This subtype of :c:type:`PyObject` represents a Python integer object.\n\n\n.. c:var:: PyTypeObject PyLong_Type\n\n This instance of :c:type:`PyTypeObject` represents the Python integer type.\n This is the same object as :class:`int` in the Python layer.\n\n\n.. c:function:: int PyLong_Check(PyObject *p)\n\n Return true if its argument is a :c:type:`PyLongObject` or a subtype of\n :c:type:`PyLongObject`. This function always succeeds.\n\n\n.. c:function:: int PyLong_CheckExact(PyObject *p)\n\n Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of\n :c:type:`PyLongObject`. This function always succeeds.\n\n\n.. c:function:: PyObject* PyLong_FromLong(long v)\n\n Return a new :c:type:`PyLongObject` object from *v*, or ``NULL`` on failure.\n\n The current implementation keeps an array of integer objects for all integers\n between ``-5`` and ``256``. When you create an int in that range you actually\n just get back a reference to the existing object.\n\n\n.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromSize_t(size_t v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromLongLong(long long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`long long`, or ``NULL``\n on failure.\n\n\n.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long long`,\n or ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromDouble(double v)\n\n Return a new :c:type:`PyLongObject` object from the integer part of *v*, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)\n\n Return a new :c:type:`PyLongObject` based on the string value in *str*, which\n is interpreted according to the radix in *base*, or ``NULL`` on failure. If\n *pend* is non-``NULL``, *\\*pend* will point to the end of *str* on success or\n to the first character that could not be processed on error. If *base* is ``0``,\n *str* is interpreted using the :ref:`integers` definition; in this case, leading\n zeros in a non-zero decimal number raises a :exc:`ValueError`. If *base* is not\n ``0``, it must be between ``2`` and ``36``, inclusive. Leading and trailing\n whitespace and single underscores after a base specifier and between digits are\n ignored. If there are no digits or *str* is not NULL-terminated following the\n digits and trailing whitespace, :exc:`ValueError` will be raised.\n\n .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`\n to convert a :c:type:`PyLongObject` to/from an array of bytes in base\n ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.\n\n\n.. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)\n\n Convert a sequence of Unicode digits in the string *u* to a Python integer\n value.\n\n .. versionadded:: 3.3\n\n\n.. c:function:: PyObject* PyLong_FromVoidPtr(void *p)\n\n Create a Python integer from the pointer *p*. The pointer value can be\n retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.\n\n\n.. c:function:: PyObject* PyLong_FromNativeBytes(const void* buffer, size_t n_bytes, int flags)\n\n""]","["" be large enough to hold the value. This may be larger than technically\n necessary, but not unreasonably so. If *n_bytes=0*, *buffer* may be\n ``NULL``.\n\n .. note::\n\n Passing *n_bytes=0* to this function is not an accurate way to determine\n the bit length of the value.\n\n To get at the entire Python value of an unknown size, the function can be\n called twice: first to determine the buffer size, then to fill it::\n\n // Ask how much space we need.\n Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n if (expected < 0) {\n // Failed. A Python exception was set with the reason.\n return NULL;\n }\n assert(expected != 0); // Impossible per the API definition.\n uint8_t *bignum = malloc(expected);\n if (!bignum) {\n PyErr_SetString(PyExc_MemoryError, \""bignum malloc failed.\"");\n return NULL;\n }\n // Safely get the entire value.\n Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);\n if (bytes < 0) { // Exception has been set.\n free(bignum);\n return NULL;\n }\n else if (bytes > expected) { // This should not be possible.\n PyErr_SetString(PyExc_RuntimeError,\n \""Unexpected bignum truncation after a size check.\"");\n free(bignum);\n return NULL;\n }\n // The expected success given the above pre-check.\n // ... use bignum ...\n free(bignum);\n\n *flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults\n that behave most like a C cast, or a combintation of the other flags in\n the table below.\n Note that ``-1`` cannot be combined with other flags.\n\n Currently, ``-1`` corresponds to\n ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | Py_ASNATIVEBYTES_UNSIGNED_BUFFER``.\n\n .. c:namespace:: NULL\n\n ============================================= ======\n Flag Value\n ============================================= ======\n .. c:macro:: Py_ASNATIVEBYTES_DEFAULTS ``-1``\n .. c:macro:: Py_ASNATIVEBYTES_BIG_ENDIAN ``0``\n .. c:macro:: Py_ASNATIVEBYTES_LITTLE_ENDIAN ``1``\n .. c:macro:: Py_ASNATIVEBYTES_NATIVE_ENDIAN ``3``\n .. c:macro:: Py_ASNATIVEBYTES_UNSIGNED_BUFFER ``4``\n .. c:macro:: Py_ASNATIVEBYTES_REJECT_NEGATIVE ``8``\n .. c:macro:: Py_ASNATIVEBYTES_ALLOW_INDEX ``16``\n ============================================= ======\n\n Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian\n flags. Passing ``2`` is reserved.\n\n By default, sufficient buffer will be requested to include a sign bit.\n For example, when converting 128 with *n_bytes=1*, the function will return\n 2 (or more) in order to store a zero sign bit.\n\n If ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` is specified, a zero sign bit\n will be omitted from size calculations. This allows, for example, 128 to fit\n in a single-byte buffer. If the destination buffer is later treated as\n signed, a positive input value may become negative.\n Note that the flag does not affect handling of negative values: for those,\n space for a sign bit is always requested.\n\n Specifying ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` causes an exception to be set\n if *pylong* is negative. Without this flag, negative values will be copied\n provided there is enough space for at least one sign bit, regardless of\n whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified.\n\n If ``Py_ASNATIVEBYTES_ALLOW_INDEX`` is specified and a non-integer value is\n passed, its :meth:`~object.__index__` method will be called first. This may\n result in Python code executing and other threads being allowed to run, which\n could cause changes to other objects or values in use. When *flags* is\n ``-1``, this option is not set, and non-integer values will raise\n :exc:`TypeError`.\n\n .. note::\n\n With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without\n *REJECT_NEGATIVE*), multiple Python integers can map to a single value\n without overflow. For example, both ``255`` and ``-1`` fit a single-byte\n buffer and set all its bits.\n This matches typical C cast behavior.\n\n .. versionadded:: 3.13\n\n\n.. c:function:: PyObject* PyLong_GetInfo(void)\n\n On success, return a read only :term:`named tuple`, that holds\n information about Python's internal representation of integers.\n See :data:`sys.int_info` for description of individual fields.\n\n On failure, return ``NULL`` with an exception set.\n\n .. versionadded:: 3.1\n\n\n.. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op)\n\n Return 1 if *op* is compact, 0 otherwise.\n\n This function makes it possible for performance-critical code to implement\n a “fast path” for small integers. For compact values use\n :c:func:`PyUnstable_Long_CompactValue`; for others fall back to a\n :c:func:`PyLong_As* ` function or\n :c:func:`PyLong_AsNativeBytes`.\n\n The speedup is expected to be negligible for most users.\n\n Exactly what values are considered compact is an implementation detail\n and is subject to change.\n\n.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)\n\n If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,\n return its value.\n\n Otherwise, the return value is undefined.\n\n"", ""\n Create a Python integer from the pointer *p*. The pointer value can be\n retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.\n\n\n.. c:function:: PyObject* PyLong_FromNativeBytes(const void* buffer, size_t n_bytes, int flags)\n\n Create a Python integer from the value contained in the first *n_bytes* of\n *buffer*, interpreted as a two's-complement signed number.\n\n *flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will select\n the native endian that CPython was compiled with and assume that the\n most-significant bit is a sign bit. Passing\n ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` will produce the same result as calling\n :c:func:`PyLong_FromUnsignedNativeBytes`. Other flags are ignored.\n\n .. versionadded:: 3.13\n\n\n.. c:function:: PyObject* PyLong_FromUnsignedNativeBytes(const void* buffer, size_t n_bytes, int flags)\n\n Create a Python integer from the value contained in the first *n_bytes* of\n *buffer*, interpreted as an unsigned number.\n\n *flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will select\n the native endian that CPython was compiled with and assume that the\n most-significant bit is not a sign bit. Flags other than endian are ignored.\n\n .. versionadded:: 3.13\n\n\n.. c:function:: long PyLong_AsLong(PyObject *obj)\n\n .. index::\n single: LONG_MAX (C macro)\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method\n (if present) to convert it to a :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *obj* is out of range for a\n :c:expr:`long`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n .. c:namespace:: NULL\n\n .. c:function:: long PyLong_AS_LONG(PyObject *obj)\n\n A :term:`soft deprecated` alias.\n Exactly equivalent to the preferred ``PyLong_AsLong``. In particular,\n it can fail with :exc:`OverflowError` or another exception.\n\n .. deprecated:: 3.14\n The function is soft deprecated.\n\n.. c:function:: int PyLong_AsInt(PyObject *obj)\n\n Similar to :c:func:`PyLong_AsLong`, but store the result in a C\n :c:expr:`int` instead of a C :c:expr:`long`.\n\n .. versionadded:: 3.13\n\n\n.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)\n\n Return a C :c:expr:`long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`\n method (if present) to convert it to a :c:type:`PyLongObject`.\n\n If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than\n :c:macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and\n return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other exception\n occurs set *\\*overflow* to ``0`` and return ``-1`` as usual.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: long long PyLong_AsLongLong(PyObject *obj)\n\n .. index::\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method\n (if present) to convert it to a :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *obj* is out of range for a\n :c:expr:`long long`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/long.rst#codepoints:36:4018"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/long.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-c-api-long.rst-head0,dp-Python-c-api-long.rst,Python 3.12.7 documentation: Integer Objects,"[""Integer Objects\n---------------\n\n.. index:: pair: object; long integer\n pair: object; integer\n\nAll integers are implemented as \""long\"" integer objects of arbitrary size.\n\nOn error, most ``PyLong_As*`` APIs return ``(return type)-1`` which cannot be\ndistinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n.. c:type:: PyLongObject\n\n This subtype of :c:type:`PyObject` represents a Python integer object.\n\n\n.. c:var:: PyTypeObject PyLong_Type\n\n This instance of :c:type:`PyTypeObject` represents the Python integer type.\n This is the same object as :class:`int` in the Python layer.\n\n\n.. c:function:: int PyLong_Check(PyObject *p)\n\n Return true if its argument is a :c:type:`PyLongObject` or a subtype of\n :c:type:`PyLongObject`. This function always succeeds.\n\n\n.. c:function:: int PyLong_CheckExact(PyObject *p)\n\n Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of\n :c:type:`PyLongObject`. This function always succeeds.\n\n\n.. c:function:: PyObject* PyLong_FromLong(long v)\n\n Return a new :c:type:`PyLongObject` object from *v*, or ``NULL`` on failure.\n\n The current implementation keeps an array of integer objects for all integers\n between ``-5`` and ``256``. When you create an int in that range you actually\n just get back a reference to the existing object.\n\n\n.. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromSize_t(size_t v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromLongLong(long long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`long long`, or ``NULL``\n on failure.\n\n\n.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)\n\n Return a new :c:type:`PyLongObject` object from a C :c:expr:`unsigned long long`,\n or ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromDouble(double v)\n\n Return a new :c:type:`PyLongObject` object from the integer part of *v*, or\n ``NULL`` on failure.\n\n\n.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)\n\n Return a new :c:type:`PyLongObject` based on the string value in *str*, which\n is interpreted according to the radix in *base*, or ``NULL`` on failure. If\n *pend* is non-``NULL``, *\\*pend* will point to the end of *str* on success or\n to the first character that could not be processed on error. If *base* is ``0``,\n *str* is interpreted using the :ref:`integers` definition; in this case, leading\n zeros in a non-zero decimal number raises a :exc:`ValueError`. If *base* is not\n ``0``, it must be between ``2`` and ``36``, inclusive. Leading and trailing\n whitespace and single underscores after a base specifier and between digits are\n ignored. If there are no digits or *str* is not NULL-terminated following the\n digits and trailing whitespace, :exc:`ValueError` will be raised.\n\n .. seealso:: Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes`\n to convert a :c:type:`PyLongObject` to/from an array of bytes in base\n ``256``. You can call those from C using :c:func:`PyObject_CallMethod`.\n\n\n.. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)\n\n Convert a sequence of Unicode digits in the string *u* to a Python integer\n value.\n\n .. versionadded:: 3.3\n\n\n.. c:function:: PyObject* PyLong_FromVoidPtr(void *p)\n\n Create a Python integer from the pointer *p*. The pointer value can be\n retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.\n\n\n.. XXX alias PyLong_AS_LONG (for now)\n.. c:function:: long PyLong_AsLong(PyObject *obj)\n\n""]","[""\n\n.. c:function:: PyObject* PyLong_FromVoidPtr(void *p)\n\n Create a Python integer from the pointer *p*. The pointer value can be\n retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`.\n\n\n.. XXX alias PyLong_AS_LONG (for now)\n.. c:function:: long PyLong_AsLong(PyObject *obj)\n\n .. index::\n single: LONG_MAX (C macro)\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method\n (if present) to convert it to a :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *obj* is out of range for a\n :c:expr:`long`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)\n\n Return a C :c:expr:`long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`\n method (if present) to convert it to a :c:type:`PyLongObject`.\n\n If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than\n :c:macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and\n return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other exception\n occurs set *\\*overflow* to ``0`` and return ``-1`` as usual.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: long long PyLong_AsLongLong(PyObject *obj)\n\n .. index::\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method\n (if present) to convert it to a :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *obj* is out of range for a\n :c:expr:`long long`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)\n\n Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an\n instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method\n (if present) to convert it to a :c:type:`PyLongObject`.\n\n If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less than\n :c:macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively,\n and return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other\n exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionadded:: 3.2\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)\n\n .. index::\n single: PY_SSIZE_T_MAX (C macro)\n single: OverflowError (built-in exception)\n\n Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must\n be an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for a\n :c:type:`Py_ssize_t`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)\n\n"", "" be an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for a\n :c:type:`Py_ssize_t`.\n\n Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)\n\n .. index::\n single: ULONG_MAX (C macro)\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`unsigned long` representation of *pylong*. *pylong*\n must be an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for a\n :c:expr:`unsigned long`.\n\n Returns ``(unsigned long)-1`` on error.\n Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: size_t PyLong_AsSize_t(PyObject *pylong)\n\n .. index::\n single: SIZE_MAX (C macro)\n single: OverflowError (built-in exception)\n\n Return a C :c:type:`size_t` representation of *pylong*. *pylong* must be\n an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for a\n :c:type:`size_t`.\n\n Returns ``(size_t)-1`` on error.\n Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: unsigned long long PyLong_AsUnsignedLongLong(PyObject *pylong)\n\n .. index::\n single: OverflowError (built-in exception)\n\n Return a C :c:expr:`unsigned long long` representation of *pylong*. *pylong*\n must be an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for an\n :c:expr:`unsigned long long`.\n\n Returns ``(unsigned long long)-1`` on error.\n Use :c:func:`PyErr_Occurred` to disambiguate.\n\n .. versionchanged:: 3.1\n A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`.\n\n\n.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)\n\n Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not\n an instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`\n method (if present) to convert it to a :c:type:`PyLongObject`.\n\n If the value of *obj* is out of range for an :c:expr:`unsigned long`,\n return the reduction of that value modulo ``ULONG_MAX + 1``.\n\n Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to\n disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)\n\n Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj*\n is not an instance of :c:type:`PyLongObject`, first call its\n :meth:`~object.__index__` method (if present) to convert it to a\n :c:type:`PyLongObject`.\n\n If the value of *obj* is out of range for an :c:expr:`unsigned long long`,\n return the reduction of that value modulo ``ULLONG_MAX + 1``.\n\n Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred`\n to disambiguate.\n\n .. versionchanged:: 3.8\n Use :meth:`~object.__index__` if available.\n\n .. versionchanged:: 3.10\n This function will no longer use :meth:`~object.__int__`.\n\n\n.. c:function:: double PyLong_AsDouble(PyObject *pylong)\n\n Return a C :c:expr:`double` representation of *pylong*. *pylong* must be\n an instance of :c:type:`PyLongObject`.\n\n Raise :exc:`OverflowError` if the value of *pylong* is out of range for a\n :c:expr:`double`.\n\n Returns ``-1.0`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong)\n\n Convert a Python integer *pylong* to a C :c:expr:`void` pointer.\n If *pylong* cannot be converted, an :exc:`OverflowError` will be raised. This\n is only assured to produce a usable :c:expr:`void` pointer for values created\n with :c:func:`PyLong_FromVoidPtr`.\n\n Returns ``NULL`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.\n\n\n.. c:function:: PyObject* PyLong_GetInfo(void)\n\n On success, return a read only :term:`named tuple`, that holds\n information about Python's internal representation of integers.\n See :data:`sys.int_info` for description of individual fields.\n\n On failure, return ``NULL`` with an exception set.\n\n .. versionadded:: 3.1\n\n\n.. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op)\n\n Return 1 if *op* is compact, 0 otherwise.\n\n This function makes it possible for performance-critical code to implement\n a “fast path” for small integers. For compact values use\n :c:func:`PyUnstable_Long_CompactValue`; for others fall back to a\n :c:func:`PyLong_As* ` function or\n :c:func:`calling ` :meth:`int.to_bytes`.\n\n The speedup is expected to be negligible for most users.\n\n Exactly what values are considered compact is an implementation detail\n and is subject to change.\n\n.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)\n\n If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,\n return its value.\n\n Otherwise, the return value is undefined.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/c-api/long.rst#codepoints:36:4010"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:c-api/long.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-c-api-memory.rst-head0,dp-Python-c-api-memory.rst,Python 3.13.0 documentation: Allocator Domains,"[""Allocator Domains\n=================\n\n.. _allocator-domains:\n\nAll allocating functions belong to one of three different \""domains\"" (see also\n:c:type:`PyMemAllocatorDomain`). These domains represent different allocation\nstrategies and are optimized for different purposes. The specific details on\nhow every domain allocates memory or what internal functions each domain calls\nis considered an implementation detail, but for debugging purposes a simplified\ntable can be found at :ref:`here `.\nThe APIs used to allocate and free a block of memory must be from the same domain.\nFor example, :c:func:`PyMem_Free` must be used to free memory allocated using :c:func:`PyMem_Malloc`.\n\nThe three allocation domains are:\n\n* Raw domain: intended for allocating memory for general-purpose memory\n buffers where the allocation *must* go to the system allocator or where the\n allocator can operate without the :term:`GIL`. The memory is requested directly\n from the system. See :ref:`Raw Memory Interface `.\n\n* \""Mem\"" domain: intended for allocating memory for Python buffers and\n general-purpose memory buffers where the allocation must be performed with\n the :term:`GIL` held. The memory is taken from the Python private heap.\n See :ref:`Memory Interface `.\n\n* Object domain: intended for allocating memory for Python objects. The\n memory is taken from the Python private heap. See :ref:`Object allocators `.\n\n.. note::\n\n The :term:`free-threaded ` build requires that only Python objects are allocated using the \""object\"" domain\n and that all Python objects are allocated using that domain. This differs from the prior Python versions,\n where this was only a best practice and not a hard requirement.\n\n For example, buffers (non-Python objects) should be allocated using :c:func:`PyMem_Malloc`,\n :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`, but not :c:func:`PyObject_Malloc`.\n\n See :ref:`Memory Allocation APIs `.\n\n\n.. _raw-memoryinterface:\n\n""]","[""Customize Memory Allocators\n===========================\n\n.. versionadded:: 3.4\n\n.. c:type:: PyMemAllocatorEx\n\n Structure used to describe a memory block allocator. The structure has\n the following fields:\n\n +----------------------------------------------------------+---------------------------------------+\n | Field | Meaning |\n +==========================================================+=======================================+\n | ``void *ctx`` | user context passed as first argument |\n +----------------------------------------------------------+---------------------------------------+\n | ``void* malloc(void *ctx, size_t size)`` | allocate a memory block |\n +----------------------------------------------------------+---------------------------------------+\n | ``void* calloc(void *ctx, size_t nelem, size_t elsize)`` | allocate a memory block initialized |\n | | with zeros |\n +----------------------------------------------------------+---------------------------------------+\n | ``void* realloc(void *ctx, void *ptr, size_t new_size)`` | allocate or resize a memory block |\n +----------------------------------------------------------+---------------------------------------+\n | ``void free(void *ctx, void *ptr)`` | free a memory block |\n +----------------------------------------------------------+---------------------------------------+\n\n .. versionchanged:: 3.5\n The :c:type:`!PyMemAllocator` structure was renamed to\n :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added.\n\n\n.. c:type:: PyMemAllocatorDomain\n\n Enum used to identify an allocator domain. Domains:\n\n .. c:namespace:: NULL\n\n .. c:macro:: PYMEM_DOMAIN_RAW\n\n Functions:\n\n * :c:func:`PyMem_RawMalloc`\n * :c:func:`PyMem_RawRealloc`\n * :c:func:`PyMem_RawCalloc`\n * :c:func:`PyMem_RawFree`\n\n .. c:macro:: PYMEM_DOMAIN_MEM\n\n Functions:\n\n * :c:func:`PyMem_Malloc`,\n * :c:func:`PyMem_Realloc`\n * :c:func:`PyMem_Calloc`\n * :c:func:`PyMem_Free`\n\n .. c:macro:: PYMEM_DOMAIN_OBJ\n\n Functions:\n\n * :c:func:`PyObject_Malloc`\n * :c:func:`PyObject_Realloc`\n * :c:func:`PyObject_Calloc`\n * :c:func:`PyObject_Free`\n\n.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)\n\n Get the memory block allocator of the specified domain.\n\n\n.. c:function:: void PyMem_SetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)\n\n Set the memory block allocator of the specified domain.\n\n The new allocator must return a distinct non-``NULL`` pointer when requesting\n zero bytes.\n\n For the :c:macro:`PYMEM_DOMAIN_RAW` domain, the allocator must be\n thread-safe: the :term:`GIL ` is not held when the\n allocator is called.\n\n For the remaining domains, the allocator must also be thread-safe:\n the allocator may be called in different interpreters that do not\n share a ``GIL``.\n\n If the new allocator is not a hook (does not call the previous allocator),\n the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the\n debug hooks on top on the new allocator.\n\n See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python\n with PyPreConfig `.\n\n .. warning::\n\n :c:func:`PyMem_SetAllocator` does have the following contract:\n\n * It can be called after :c:func:`Py_PreInitialize` and before\n :c:func:`Py_InitializeFromConfig` to install a custom memory\n allocator. There are no restrictions over the installed allocator\n other than the ones imposed by the domain (for instance, the Raw\n Domain allows the allocator to be called without the GIL held). See\n :ref:`the section on allocator domains ` for more\n information.\n\n * If called after Python has finish initializing (after\n :c:func:`Py_InitializeFromConfig` has been called) the allocator\n **must** wrap the existing allocator. Substituting the current\n allocator for some other arbitrary one is **not supported**.\n\n .. versionchanged:: 3.12\n All allocators must be thread-safe.\n\n\n.. c:function:: void PyMem_SetupDebugHooks(void)\n\n Setup :ref:`debug hooks in the Python memory allocators `\n to detect memory errors.\n\n\n.. _pymem-debug-hooks:\n\n"", ""Debug hooks on the Python memory allocators\n===========================================\n\nWhen :ref:`Python is built in debug mode `, the\n:c:func:`PyMem_SetupDebugHooks` function is called at the :ref:`Python\npreinitialization ` to setup debug hooks on Python memory allocators\nto detect memory errors.\n\nThe :envvar:`PYTHONMALLOC` environment variable can be used to install debug\nhooks on a Python compiled in release mode (ex: ``PYTHONMALLOC=debug``).\n\nThe :c:func:`PyMem_SetupDebugHooks` function can be used to set debug hooks\nafter calling :c:func:`PyMem_SetAllocator`.\n\nThese debug hooks fill dynamically allocated memory blocks with special,\nrecognizable bit patterns. Newly allocated memory is filled with the byte\n``0xCD`` (``PYMEM_CLEANBYTE``), freed memory is filled with the byte ``0xDD``\n(``PYMEM_DEADBYTE``). Memory blocks are surrounded by \""forbidden bytes\""\nfilled with the byte ``0xFD`` (``PYMEM_FORBIDDENBYTE``). Strings of these bytes\nare unlikely to be valid addresses, floats, or ASCII strings.\n\nRuntime checks:\n\n- Detect API violations. For example, detect if :c:func:`PyObject_Free` is\n called on a memory block allocated by :c:func:`PyMem_Malloc`.\n- Detect write before the start of the buffer (buffer underflow).\n- Detect write after the end of the buffer (buffer overflow).\n- Check that the :term:`GIL ` is held when\n allocator functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex:\n :c:func:`PyObject_Malloc`) and :c:macro:`PYMEM_DOMAIN_MEM` (ex:\n :c:func:`PyMem_Malloc`) domains are called.\n\nOn error, the debug hooks use the :mod:`tracemalloc` module to get the\ntraceback where a memory block was allocated. The traceback is only displayed\nif :mod:`tracemalloc` is tracing Python memory allocations and the memory block\nwas traced.\n\nLet *S* = ``sizeof(size_t)``. ``2*S`` bytes are added at each end of each block\nof *N* bytes requested. The memory layout is like so, where p represents the\naddress returned by a malloc-like or realloc-like function (``p[i:j]`` means\nthe slice of bytes from ``*(p+i)`` inclusive up to ``*(p+j)`` exclusive; note\nthat the treatment of negative indices differs from a Python slice):\n\n``p[-2*S:-S]``\n Number of bytes originally asked for. This is a size_t, big-endian (easier\n to read in a memory dump).\n``p[-S]``\n API identifier (ASCII character):\n\n * ``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`.\n * ``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`.\n * ``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`.\n\n``p[-S+1:0]``\n Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads.\n\n``p[0:N]``\n The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch\n reference to uninitialized memory. When a realloc-like function is called\n requesting a larger memory block, the new excess bytes are also filled with\n PYMEM_CLEANBYTE. When a free-like function is called, these are\n overwritten with PYMEM_DEADBYTE, to catch reference to freed memory. When\n a realloc- like function is called requesting a smaller memory block, the\n excess old bytes are also filled with PYMEM_DEADBYTE.\n\n``p[N:N+S]``\n Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads.\n\n``p[N+S:N+2*S]``\n Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by\n default).\n\n A serial number, incremented by 1 on each call to a malloc-like or\n realloc-like function. Big-endian :c:type:`size_t`. If \""bad memory\"" is detected\n later, the serial number gives an excellent way to set a breakpoint on the\n next run, to capture the instant at which this block was passed out. The\n static function bumpserialno() in obmalloc.c is the only place the serial\n number is incremented, and exists so you can set such a breakpoint easily.\n\nA realloc-like or free-like function first checks that the PYMEM_FORBIDDENBYTE\nbytes at each end are intact. If they've been altered, diagnostic output is\nwritten to stderr, and the program is aborted via Py_FatalError(). The other\nmain failure mode is provoking a memory error when a program reads up one of\nthe special bit patterns and tries to use it as an address. If you get in a\ndebugger then and look at the object, you're likely to see that it's entirely\nfilled with PYMEM_DEADBYTE (meaning freed memory is getting used) or\nPYMEM_CLEANBYTE (meaning uninitialized memory is getting used).\n\n.. versionchanged:: 3.6\n The :c:func:`PyMem_SetupDebugHooks` function now also works on Python\n compiled in release mode. On error, the debug hooks now use\n :mod:`tracemalloc` to get the traceback where a memory block was allocated.\n The debug hooks now also check if the GIL is held when functions of\n :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are\n called.\n\n.. versionchanged:: 3.8\n Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``)\n and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``,\n ``0xDD`` and ``0xFD`` to use the same values than Windows CRT debug\n ``malloc()`` and ``free()``.\n\n\n.. _pymalloc:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/memory.rst#codepoints:4218:6292"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-memory.rst-head1,dp-Python-c-api-memory.rst,Python 3.13.0 documentation: Object allocators,"[""Object allocators\n=================\n\nThe following function sets, modeled after the ANSI C standard, but specifying\nbehavior when requesting zero bytes, are available for allocating and releasing\nmemory from the Python heap.\n\n.. note::\n There is no guarantee that the memory returned by these allocators can be\n successfully cast to a Python object when intercepting the allocating\n functions in this domain by the methods described in\n the :ref:`Customize Memory Allocators ` section.\n\nThe :ref:`default object allocator ` uses the\n:ref:`pymalloc memory allocator `.\n\n.. warning::\n\n The :term:`GIL ` must be held when using these\n functions.\n\n.. c:function:: void* PyObject_Malloc(size_t n)\n\n Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the\n allocated memory, or ``NULL`` if the request fails.\n\n Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, as\n if ``PyObject_Malloc(1)`` had been called instead. The memory will not have\n been initialized in any way.\n\n\n.. c:function:: void* PyObject_Calloc(size_t nelem, size_t elsize)\n\n Allocates *nelem* elements each whose size in bytes is *elsize* and returns\n a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the\n request fails. The memory is initialized to zeros.\n\n Requesting zero elements or elements of size zero bytes returns a distinct\n non-``NULL`` pointer if possible, as if ``PyObject_Calloc(1, 1)`` had been called\n instead.\n\n .. versionadded:: 3.5\n\n\n.. c:function:: void* PyObject_Realloc(void *p, size_t n)\n\n Resizes the memory block pointed to by *p* to *n* bytes. The contents will be\n unchanged to the minimum of the old and the new sizes.\n\n If *p* is ``NULL``, the call is equivalent to ``PyObject_Malloc(n)``; else if *n*\n is equal to zero, the memory block is resized but is not freed, and the\n returned pointer is non-``NULL``.\n\n Unless *p* is ``NULL``, it must have been returned by a previous call to\n :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:`PyObject_Calloc`.\n\n If the request fails, :c:func:`PyObject_Realloc` returns ``NULL`` and *p* remains\n a valid pointer to the previous memory area.\n\n\n.. c:function:: void PyObject_Free(void *p)\n\n Frees the memory block pointed to by *p*, which must have been returned by a\n previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or\n :c:func:`PyObject_Calloc`. Otherwise, or if ``PyObject_Free(p)`` has been called\n before, undefined behavior occurs.\n\n If *p* is ``NULL``, no operation is performed.\n\n\n.. _default-memory-allocators:\n\n""]","[""Overview\n========\n\nMemory management in Python involves a private heap containing all Python\nobjects and data structures. The management of this private heap is ensured\ninternally by the *Python memory manager*. The Python memory manager has\ndifferent components which deal with various dynamic storage management aspects,\nlike sharing, segmentation, preallocation or caching.\n\nAt the lowest level, a raw memory allocator ensures that there is enough room in\nthe private heap for storing all Python-related data by interacting with the\nmemory manager of the operating system. On top of the raw memory allocator,\nseveral object-specific allocators operate on the same heap and implement\ndistinct memory management policies adapted to the peculiarities of every object\ntype. For example, integer objects are managed differently within the heap than\nstrings, tuples or dictionaries because integers imply different storage\nrequirements and speed/space tradeoffs. The Python memory manager thus delegates\nsome of the work to the object-specific allocators, but ensures that the latter\noperate within the bounds of the private heap.\n\nIt is important to understand that the management of the Python heap is\nperformed by the interpreter itself and that the user has no control over it,\neven if they regularly manipulate object pointers to memory blocks inside that\nheap. The allocation of heap space for Python objects and other internal\nbuffers is performed on demand by the Python memory manager through the Python/C\nAPI functions listed in this document.\n\n.. index::\n single: malloc (C function)\n single: calloc (C function)\n single: realloc (C function)\n single: free (C function)\n\nTo avoid memory corruption, extension writers should never try to operate on\nPython objects with the functions exported by the C library: :c:func:`malloc`,\n:c:func:`calloc`, :c:func:`realloc` and :c:func:`free`. This will result in mixed\ncalls between the C allocator and the Python memory manager with fatal\nconsequences, because they implement different algorithms and operate on\ndifferent heaps. However, one may safely allocate and release memory blocks\nwith the C library allocator for individual purposes, as shown in the following\nexample::\n\n PyObject *res;\n char *buf = (char *) malloc(BUFSIZ); /* for I/O */\n\n if (buf == NULL)\n return PyErr_NoMemory();\n ...Do some I/O operation involving buf...\n res = PyBytes_FromString(buf);\n free(buf); /* malloc'ed */\n return res;\n\nIn this example, the memory request for the I/O buffer is handled by the C\nlibrary allocator. The Python memory manager is involved only in the allocation\nof the bytes object returned as a result.\n\nIn most situations, however, it is recommended to allocate memory from the\nPython heap specifically because the latter is under control of the Python\nmemory manager. For example, this is required when the interpreter is extended\nwith new object types written in C. Another reason for using the Python heap is\nthe desire to *inform* the Python memory manager about the memory needs of the\nextension module. Even when the requested memory is used exclusively for\ninternal, highly specific purposes, delegating all memory requests to the Python\nmemory manager causes the interpreter to have a more accurate image of its\nmemory footprint as a whole. Consequently, under certain circumstances, the\nPython memory manager may or may not trigger appropriate actions, like garbage\ncollection, memory compaction or other preventive procedures. Note that by using\nthe C library allocator as shown in the previous example, the allocated memory\nfor the I/O buffer escapes completely the Python memory manager.\n\n.. seealso::\n\n The :envvar:`PYTHONMALLOC` environment variable can be used to configure\n the memory allocators used by Python.\n\n The :envvar:`PYTHONMALLOCSTATS` environment variable can be used to print\n statistics of the :ref:`pymalloc memory allocator ` every time a\n new pymalloc object arena is created, and on shutdown.\n\n"", ""Debug hooks on the Python memory allocators\n===========================================\n\nWhen :ref:`Python is built in debug mode `, the\n:c:func:`PyMem_SetupDebugHooks` function is called at the :ref:`Python\npreinitialization ` to setup debug hooks on Python memory allocators\nto detect memory errors.\n\nThe :envvar:`PYTHONMALLOC` environment variable can be used to install debug\nhooks on a Python compiled in release mode (ex: ``PYTHONMALLOC=debug``).\n\nThe :c:func:`PyMem_SetupDebugHooks` function can be used to set debug hooks\nafter calling :c:func:`PyMem_SetAllocator`.\n\nThese debug hooks fill dynamically allocated memory blocks with special,\nrecognizable bit patterns. Newly allocated memory is filled with the byte\n``0xCD`` (``PYMEM_CLEANBYTE``), freed memory is filled with the byte ``0xDD``\n(``PYMEM_DEADBYTE``). Memory blocks are surrounded by \""forbidden bytes\""\nfilled with the byte ``0xFD`` (``PYMEM_FORBIDDENBYTE``). Strings of these bytes\nare unlikely to be valid addresses, floats, or ASCII strings.\n\nRuntime checks:\n\n- Detect API violations. For example, detect if :c:func:`PyObject_Free` is\n called on a memory block allocated by :c:func:`PyMem_Malloc`.\n- Detect write before the start of the buffer (buffer underflow).\n- Detect write after the end of the buffer (buffer overflow).\n- Check that the :term:`GIL ` is held when\n allocator functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex:\n :c:func:`PyObject_Malloc`) and :c:macro:`PYMEM_DOMAIN_MEM` (ex:\n :c:func:`PyMem_Malloc`) domains are called.\n\nOn error, the debug hooks use the :mod:`tracemalloc` module to get the\ntraceback where a memory block was allocated. The traceback is only displayed\nif :mod:`tracemalloc` is tracing Python memory allocations and the memory block\nwas traced.\n\nLet *S* = ``sizeof(size_t)``. ``2*S`` bytes are added at each end of each block\nof *N* bytes requested. The memory layout is like so, where p represents the\naddress returned by a malloc-like or realloc-like function (``p[i:j]`` means\nthe slice of bytes from ``*(p+i)`` inclusive up to ``*(p+j)`` exclusive; note\nthat the treatment of negative indices differs from a Python slice):\n\n``p[-2*S:-S]``\n Number of bytes originally asked for. This is a size_t, big-endian (easier\n to read in a memory dump).\n``p[-S]``\n API identifier (ASCII character):\n\n * ``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`.\n * ``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`.\n * ``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`.\n\n``p[-S+1:0]``\n Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads.\n\n``p[0:N]``\n The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch\n reference to uninitialized memory. When a realloc-like function is called\n requesting a larger memory block, the new excess bytes are also filled with\n PYMEM_CLEANBYTE. When a free-like function is called, these are\n overwritten with PYMEM_DEADBYTE, to catch reference to freed memory. When\n a realloc- like function is called requesting a smaller memory block, the\n excess old bytes are also filled with PYMEM_DEADBYTE.\n\n``p[N:N+S]``\n Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads.\n\n``p[N+S:N+2*S]``\n Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by\n default).\n\n A serial number, incremented by 1 on each call to a malloc-like or\n realloc-like function. Big-endian :c:type:`size_t`. If \""bad memory\"" is detected\n later, the serial number gives an excellent way to set a breakpoint on the\n next run, to capture the instant at which this block was passed out. The\n static function bumpserialno() in obmalloc.c is the only place the serial\n number is incremented, and exists so you can set such a breakpoint easily.\n\nA realloc-like or free-like function first checks that the PYMEM_FORBIDDENBYTE\nbytes at each end are intact. If they've been altered, diagnostic output is\nwritten to stderr, and the program is aborted via Py_FatalError(). The other\nmain failure mode is provoking a memory error when a program reads up one of\nthe special bit patterns and tries to use it as an address. If you get in a\ndebugger then and look at the object, you're likely to see that it's entirely\nfilled with PYMEM_DEADBYTE (meaning freed memory is getting used) or\nPYMEM_CLEANBYTE (meaning uninitialized memory is getting used).\n\n.. versionchanged:: 3.6\n The :c:func:`PyMem_SetupDebugHooks` function now also works on Python\n compiled in release mode. On error, the debug hooks now use\n :mod:`tracemalloc` to get the traceback where a memory block was allocated.\n The debug hooks now also check if the GIL is held when functions of\n :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are\n called.\n\n.. versionchanged:: 3.8\n Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``)\n and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``,\n ``0xDD`` and ``0xFD`` to use the same values than Windows CRT debug\n ``malloc()`` and ``free()``.\n\n\n.. _pymalloc:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/memory.rst#codepoints:12481:15199"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-c-api-memory.rst-head2,dp-Python-c-api-memory.rst,Python 3.13.0 documentation: The pymalloc allocator,"[""The pymalloc allocator\n======================\n\nPython has a *pymalloc* allocator optimized for small objects (smaller or equal\nto 512 bytes) with a short lifetime. It uses memory mappings called \""arenas\""\nwith a fixed size of either 256 KiB on 32-bit platforms or 1 MiB on 64-bit\nplatforms. It falls back to :c:func:`PyMem_RawMalloc` and\n:c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes.\n\n*pymalloc* is the :ref:`default allocator ` of the\n:c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and\n:c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains.\n\nThe arena allocator uses the following functions:\n\n* :c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows,\n* :c:func:`!mmap` and :c:func:`!munmap` if available,\n* :c:func:`malloc` and :c:func:`free` otherwise.\n\nThis allocator is disabled if Python is configured with the\n:option:`--without-pymalloc` option. It can also be disabled at runtime using\nthe :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``).\n\nCustomize pymalloc Arena Allocator\n----------------------------------\n\n.. versionadded:: 3.4\n\n.. c:type:: PyObjectArenaAllocator\n\n Structure used to describe an arena allocator. The structure has\n three fields:\n\n +--------------------------------------------------+---------------------------------------+\n | Field | Meaning |\n +==================================================+=======================================+\n | ``void *ctx`` | user context passed as first argument |\n +--------------------------------------------------+---------------------------------------+\n | ``void* alloc(void *ctx, size_t size)`` | allocate an arena of size bytes |\n +--------------------------------------------------+---------------------------------------+\n | ``void free(void *ctx, void *ptr, size_t size)`` | free an arena |\n +--------------------------------------------------+---------------------------------------+\n\n.. c:function:: void PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Get the arena allocator.\n\n.. c:function:: void PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Set the arena allocator.\n\n.. _mimalloc:\n\nThe mimalloc allocator\n======================\n\n.. versionadded:: 3.13\n\nPython supports the mimalloc allocator when the underlying platform support is available.\nmimalloc \""is a general purpose allocator with excellent performance characteristics.\nInitially developed by Daan Leijen for the runtime systems of the Koka and Lean languages.\""\n\ntracemalloc C API\n=================\n\n.. versionadded:: 3.7\n\n.. c:function:: int PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, size_t size)\n\n Track an allocated memory block in the :mod:`tracemalloc` module.\n\n Return ``0`` on success, return ``-1`` on error (failed to allocate memory to\n store the trace). Return ``-2`` if tracemalloc is disabled.\n\n If memory block is already tracked, update the existing trace.\n\n.. c:function:: int PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)\n\n Untrack an allocated memory block in the :mod:`tracemalloc` module.\n Do nothing if the block was not tracked.\n\n Return ``-2`` if tracemalloc is disabled, otherwise return ``0``.\n\n\n.. _memoryexamples:\n\n""]","[""Overview\n========\n\nMemory management in Python involves a private heap containing all Python\nobjects and data structures. The management of this private heap is ensured\ninternally by the *Python memory manager*. The Python memory manager has\ndifferent components which deal with various dynamic storage management aspects,\nlike sharing, segmentation, preallocation or caching.\n\nAt the lowest level, a raw memory allocator ensures that there is enough room in\nthe private heap for storing all Python-related data by interacting with the\nmemory manager of the operating system. On top of the raw memory allocator,\nseveral object-specific allocators operate on the same heap and implement\ndistinct memory management policies adapted to the peculiarities of every object\ntype. For example, integer objects are managed differently within the heap than\nstrings, tuples or dictionaries because integers imply different storage\nrequirements and speed/space tradeoffs. The Python memory manager thus delegates\nsome of the work to the object-specific allocators, but ensures that the latter\noperate within the bounds of the private heap.\n\nIt is important to understand that the management of the Python heap is\nperformed by the interpreter itself and that the user has no control over it,\neven if they regularly manipulate object pointers to memory blocks inside that\nheap. The allocation of heap space for Python objects and other internal\nbuffers is performed on demand by the Python memory manager through the Python/C\nAPI functions listed in this document.\n\n.. index::\n single: malloc (C function)\n single: calloc (C function)\n single: realloc (C function)\n single: free (C function)\n\nTo avoid memory corruption, extension writers should never try to operate on\nPython objects with the functions exported by the C library: :c:func:`malloc`,\n:c:func:`calloc`, :c:func:`realloc` and :c:func:`free`. This will result in mixed\ncalls between the C allocator and the Python memory manager with fatal\nconsequences, because they implement different algorithms and operate on\ndifferent heaps. However, one may safely allocate and release memory blocks\nwith the C library allocator for individual purposes, as shown in the following\nexample::\n\n PyObject *res;\n char *buf = (char *) malloc(BUFSIZ); /* for I/O */\n\n if (buf == NULL)\n return PyErr_NoMemory();\n ...Do some I/O operation involving buf...\n res = PyBytes_FromString(buf);\n free(buf); /* malloc'ed */\n return res;\n\nIn this example, the memory request for the I/O buffer is handled by the C\nlibrary allocator. The Python memory manager is involved only in the allocation\nof the bytes object returned as a result.\n\nIn most situations, however, it is recommended to allocate memory from the\nPython heap specifically because the latter is under control of the Python\nmemory manager. For example, this is required when the interpreter is extended\nwith new object types written in C. Another reason for using the Python heap is\nthe desire to *inform* the Python memory manager about the memory needs of the\nextension module. Even when the requested memory is used exclusively for\ninternal, highly specific purposes, delegating all memory requests to the Python\nmemory manager causes the interpreter to have a more accurate image of its\nmemory footprint as a whole. Consequently, under certain circumstances, the\nPython memory manager may or may not trigger appropriate actions, like garbage\ncollection, memory compaction or other preventive procedures. Note that by using\nthe C library allocator as shown in the previous example, the allocated memory\nfor the I/O buffer escapes completely the Python memory manager.\n\n.. seealso::\n\n The :envvar:`PYTHONMALLOC` environment variable can be used to configure\n the memory allocators used by Python.\n\n The :envvar:`PYTHONMALLOCSTATS` environment variable can be used to print\n statistics of the :ref:`pymalloc memory allocator ` every time a\n new pymalloc object arena is created, and on shutdown.\n\n"", ""Memory Interface\n================\n\nThe following function sets, modeled after the ANSI C standard, but specifying\nbehavior when requesting zero bytes, are available for allocating and releasing\nmemory from the Python heap.\n\nThe :ref:`default memory allocator ` uses the\n:ref:`pymalloc memory allocator `.\n\n.. warning::\n\n The :term:`GIL ` must be held when using these\n functions.\n\n.. versionchanged:: 3.6\n\n The default allocator is now pymalloc instead of system :c:func:`malloc`.\n\n.. c:function:: void* PyMem_Malloc(size_t n)\n\n Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the\n allocated memory, or ``NULL`` if the request fails.\n\n Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, as\n if ``PyMem_Malloc(1)`` had been called instead. The memory will not have\n been initialized in any way.\n\n\n.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)\n\n Allocates *nelem* elements each whose size in bytes is *elsize* and returns\n a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the\n request fails. The memory is initialized to zeros.\n\n Requesting zero elements or elements of size zero bytes returns a distinct\n non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been called\n instead.\n\n .. versionadded:: 3.5\n\n\n.. c:function:: void* PyMem_Realloc(void *p, size_t n)\n\n Resizes the memory block pointed to by *p* to *n* bytes. The contents will be\n unchanged to the minimum of the old and the new sizes.\n\n If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if *n*\n is equal to zero, the memory block is resized but is not freed, and the\n returned pointer is non-``NULL``.\n\n Unless *p* is ``NULL``, it must have been returned by a previous call to\n :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`.\n\n If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* remains\n a valid pointer to the previous memory area.\n\n\n.. c:function:: void PyMem_Free(void *p)\n\n Frees the memory block pointed to by *p*, which must have been returned by a\n previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or\n :c:func:`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been called\n before, undefined behavior occurs.\n\n If *p* is ``NULL``, no operation is performed.\n\nThe following type-oriented macros are provided for convenience. Note that\n*TYPE* refers to any C type.\n\n\n.. c:macro:: PyMem_New(TYPE, n)\n\n Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of\n memory. Returns a pointer cast to ``TYPE*``. The memory will not have\n been initialized in any way.\n\n\n.. c:macro:: PyMem_Resize(p, TYPE, n)\n\n Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *\n sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return,\n *p* will be a pointer to the new memory area, or ``NULL`` in the event of\n failure.\n\n This is a C preprocessor macro; *p* is always reassigned. Save the original\n value of *p* to avoid losing memory when handling errors.\n\n\n.. c:function:: void PyMem_Del(void *p)\n\n Same as :c:func:`PyMem_Free`.\n\nIn addition, the following macro sets are provided for calling the Python memory\nallocator directly, without involving the C API functions listed above. However,\nnote that their use does not preserve binary compatibility across Python\nversions and is therefore deprecated in extension modules.\n\n* ``PyMem_MALLOC(size)``\n* ``PyMem_NEW(type, size)``\n* ``PyMem_REALLOC(ptr, size)``\n* ``PyMem_RESIZE(ptr, type, size)``\n* ``PyMem_FREE(ptr)``\n* ``PyMem_DEL(ptr)``\n\n\n.. _objectinterface:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/c-api/memory.rst#codepoints:26569:30000"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-c-api-memory.rst-head0,dp-Python-c-api-memory.rst,Python 3.12.7 documentation: Allocator Domains,"[""Allocator Domains\n=================\n\n.. _allocator-domains:\n\nAll allocating functions belong to one of three different \""domains\"" (see also\n:c:type:`PyMemAllocatorDomain`). These domains represent different allocation\nstrategies and are optimized for different purposes. The specific details on\nhow every domain allocates memory or what internal functions each domain calls\nis considered an implementation detail, but for debugging purposes a simplified\ntable can be found at :ref:`here `. There is no hard\nrequirement to use the memory returned by the allocation functions belonging to\na given domain for only the purposes hinted by that domain (although this is the\nrecommended practice). For example, one could use the memory returned by\n:c:func:`PyMem_RawMalloc` for allocating Python objects or the memory returned\nby :c:func:`PyObject_Malloc` for allocating memory for buffers.\n\nThe three allocation domains are:\n\n* Raw domain: intended for allocating memory for general-purpose memory\n buffers where the allocation *must* go to the system allocator or where the\n allocator can operate without the :term:`GIL`. The memory is requested directly\n to the system.\n\n* \""Mem\"" domain: intended for allocating memory for Python buffers and\n general-purpose memory buffers where the allocation must be performed with\n the :term:`GIL` held. The memory is taken from the Python private heap.\n\n* Object domain: intended for allocating memory belonging to Python objects. The\n memory is taken from the Python private heap.\n\nWhen freeing memory previously allocated by the allocating functions belonging to a\ngiven domain,the matching specific deallocating functions must be used. For example,\n:c:func:`PyMem_Free` must be used to free memory allocated using :c:func:`PyMem_Malloc`.\n\n""]","[""The pymalloc allocator\n======================\n\nPython has a *pymalloc* allocator optimized for small objects (smaller or equal\nto 512 bytes) with a short lifetime. It uses memory mappings called \""arenas\""\nwith a fixed size of either 256 KiB on 32-bit platforms or 1 MiB on 64-bit\nplatforms. It falls back to :c:func:`PyMem_RawMalloc` and\n:c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes.\n\n*pymalloc* is the :ref:`default allocator ` of the\n:c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and\n:c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains.\n\nThe arena allocator uses the following functions:\n\n* :c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows,\n* :c:func:`!mmap` and :c:func:`!munmap` if available,\n* :c:func:`malloc` and :c:func:`free` otherwise.\n\nThis allocator is disabled if Python is configured with the\n:option:`--without-pymalloc` option. It can also be disabled at runtime using\nthe :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``).\n\nCustomize pymalloc Arena Allocator\n----------------------------------\n\n.. versionadded:: 3.4\n\n.. c:type:: PyObjectArenaAllocator\n\n Structure used to describe an arena allocator. The structure has\n three fields:\n\n +--------------------------------------------------+---------------------------------------+\n | Field | Meaning |\n +==================================================+=======================================+\n | ``void *ctx`` | user context passed as first argument |\n +--------------------------------------------------+---------------------------------------+\n | ``void* alloc(void *ctx, size_t size)`` | allocate an arena of size bytes |\n +--------------------------------------------------+---------------------------------------+\n | ``void free(void *ctx, void *ptr, size_t size)`` | free an arena |\n +--------------------------------------------------+---------------------------------------+\n\n.. c:function:: void PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Get the arena allocator.\n\n.. c:function:: void PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Set the arena allocator.\n\n\ntracemalloc C API\n=================\n\n.. versionadded:: 3.7\n\n.. c:function:: int PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, size_t size)\n\n Track an allocated memory block in the :mod:`tracemalloc` module.\n\n Return ``0`` on success, return ``-1`` on error (failed to allocate memory to\n store the trace). Return ``-2`` if tracemalloc is disabled.\n\n If memory block is already tracked, update the existing trace.\n\n.. c:function:: int PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)\n\n Untrack an allocated memory block in the :mod:`tracemalloc` module.\n Do nothing if the block was not tracked.\n\n Return ``-2`` if tracemalloc is disabled, otherwise return ``0``.\n\n\n.. _memoryexamples:\n\n"", ""Memory Interface\n================\n\nThe following function sets, modeled after the ANSI C standard, but specifying\nbehavior when requesting zero bytes, are available for allocating and releasing\nmemory from the Python heap.\n\nThe :ref:`default memory allocator ` uses the\n:ref:`pymalloc memory allocator `.\n\n.. warning::\n\n The :term:`GIL ` must be held when using these\n functions.\n\n.. versionchanged:: 3.6\n\n The default allocator is now pymalloc instead of system :c:func:`malloc`.\n\n.. c:function:: void* PyMem_Malloc(size_t n)\n\n Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the\n allocated memory, or ``NULL`` if the request fails.\n\n Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, as\n if ``PyMem_Malloc(1)`` had been called instead. The memory will not have\n been initialized in any way.\n\n\n.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)\n\n Allocates *nelem* elements each whose size in bytes is *elsize* and returns\n a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the\n request fails. The memory is initialized to zeros.\n\n Requesting zero elements or elements of size zero bytes returns a distinct\n non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been called\n instead.\n\n .. versionadded:: 3.5\n\n\n.. c:function:: void* PyMem_Realloc(void *p, size_t n)\n\n Resizes the memory block pointed to by *p* to *n* bytes. The contents will be\n unchanged to the minimum of the old and the new sizes.\n\n If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if *n*\n is equal to zero, the memory block is resized but is not freed, and the\n returned pointer is non-``NULL``.\n\n Unless *p* is ``NULL``, it must have been returned by a previous call to\n :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`.\n\n If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* remains\n a valid pointer to the previous memory area.\n\n\n.. c:function:: void PyMem_Free(void *p)\n\n Frees the memory block pointed to by *p*, which must have been returned by a\n previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or\n :c:func:`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been called\n before, undefined behavior occurs.\n\n If *p* is ``NULL``, no operation is performed.\n\nThe following type-oriented macros are provided for convenience. Note that\n*TYPE* refers to any C type.\n\n\n.. c:macro:: PyMem_New(TYPE, n)\n\n Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of\n memory. Returns a pointer cast to ``TYPE*``. The memory will not have\n been initialized in any way.\n\n\n.. c:macro:: PyMem_Resize(p, TYPE, n)\n\n Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *\n sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return,\n *p* will be a pointer to the new memory area, or ``NULL`` in the event of\n failure.\n\n This is a C preprocessor macro; *p* is always reassigned. Save the original\n value of *p* to avoid losing memory when handling errors.\n\n\n.. c:function:: void PyMem_Del(void *p)\n\n Same as :c:func:`PyMem_Free`.\n\nIn addition, the following macro sets are provided for calling the Python memory\nallocator directly, without involving the C API functions listed above. However,\nnote that their use does not preserve binary compatibility across Python\nversions and is therefore deprecated in extension modules.\n\n* ``PyMem_MALLOC(size)``\n* ``PyMem_NEW(type, size)``\n* ``PyMem_REALLOC(ptr, size)``\n* ``PyMem_RESIZE(ptr, type, size)``\n* ``PyMem_FREE(ptr)``\n* ``PyMem_DEL(ptr)``\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/c-api/memory.rst#codepoints:4218:6025"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-c-api-memory.rst-head1,dp-Python-c-api-memory.rst,Python 3.12.7 documentation: The pymalloc allocator,"[""The pymalloc allocator\n======================\n\nPython has a *pymalloc* allocator optimized for small objects (smaller or equal\nto 512 bytes) with a short lifetime. It uses memory mappings called \""arenas\""\nwith a fixed size of either 256 KiB on 32-bit platforms or 1 MiB on 64-bit\nplatforms. It falls back to :c:func:`PyMem_RawMalloc` and\n:c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes.\n\n*pymalloc* is the :ref:`default allocator ` of the\n:c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and\n:c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains.\n\nThe arena allocator uses the following functions:\n\n* :c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows,\n* :c:func:`!mmap` and :c:func:`!munmap` if available,\n* :c:func:`malloc` and :c:func:`free` otherwise.\n\nThis allocator is disabled if Python is configured with the\n:option:`--without-pymalloc` option. It can also be disabled at runtime using\nthe :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``).\n\nCustomize pymalloc Arena Allocator\n----------------------------------\n\n.. versionadded:: 3.4\n\n.. c:type:: PyObjectArenaAllocator\n\n Structure used to describe an arena allocator. The structure has\n three fields:\n\n +--------------------------------------------------+---------------------------------------+\n | Field | Meaning |\n +==================================================+=======================================+\n | ``void *ctx`` | user context passed as first argument |\n +--------------------------------------------------+---------------------------------------+\n | ``void* alloc(void *ctx, size_t size)`` | allocate an arena of size bytes |\n +--------------------------------------------------+---------------------------------------+\n | ``void free(void *ctx, void *ptr, size_t size)`` | free an arena |\n +--------------------------------------------------+---------------------------------------+\n\n.. c:function:: void PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Get the arena allocator.\n\n.. c:function:: void PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator)\n\n Set the arena allocator.\n\n\ntracemalloc C API\n=================\n\n.. versionadded:: 3.7\n\n.. c:function:: int PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr, size_t size)\n\n Track an allocated memory block in the :mod:`tracemalloc` module.\n\n Return ``0`` on success, return ``-1`` on error (failed to allocate memory to\n store the trace). Return ``-2`` if tracemalloc is disabled.\n\n If memory block is already tracked, update the existing trace.\n\n.. c:function:: int PyTraceMalloc_Untrack(unsigned int domain, uintptr_t ptr)\n\n Untrack an allocated memory block in the :mod:`tracemalloc` module.\n Do nothing if the block was not tracked.\n\n Return ``-2`` if tracemalloc is disabled, otherwise return ``0``.\n\n\n.. _memoryexamples:\n\n""]","[""Memory Interface\n================\n\nThe following function sets, modeled after the ANSI C standard, but specifying\nbehavior when requesting zero bytes, are available for allocating and releasing\nmemory from the Python heap.\n\nThe :ref:`default memory allocator ` uses the\n:ref:`pymalloc memory allocator `.\n\n.. warning::\n\n The :term:`GIL ` must be held when using these\n functions.\n\n.. versionchanged:: 3.6\n\n The default allocator is now pymalloc instead of system :c:func:`malloc`.\n\n.. c:function:: void* PyMem_Malloc(size_t n)\n\n Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the\n allocated memory, or ``NULL`` if the request fails.\n\n Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, as\n if ``PyMem_Malloc(1)`` had been called instead. The memory will not have\n been initialized in any way.\n\n\n.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)\n\n Allocates *nelem* elements each whose size in bytes is *elsize* and returns\n a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the\n request fails. The memory is initialized to zeros.\n\n Requesting zero elements or elements of size zero bytes returns a distinct\n non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been called\n instead.\n\n .. versionadded:: 3.5\n\n\n.. c:function:: void* PyMem_Realloc(void *p, size_t n)\n\n Resizes the memory block pointed to by *p* to *n* bytes. The contents will be\n unchanged to the minimum of the old and the new sizes.\n\n If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if *n*\n is equal to zero, the memory block is resized but is not freed, and the\n returned pointer is non-``NULL``.\n\n Unless *p* is ``NULL``, it must have been returned by a previous call to\n :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`.\n\n If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* remains\n a valid pointer to the previous memory area.\n\n\n.. c:function:: void PyMem_Free(void *p)\n\n Frees the memory block pointed to by *p*, which must have been returned by a\n previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or\n :c:func:`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been called\n before, undefined behavior occurs.\n\n If *p* is ``NULL``, no operation is performed.\n\nThe following type-oriented macros are provided for convenience. Note that\n*TYPE* refers to any C type.\n\n\n.. c:macro:: PyMem_New(TYPE, n)\n\n Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of\n memory. Returns a pointer cast to ``TYPE*``. The memory will not have\n been initialized in any way.\n\n\n.. c:macro:: PyMem_Resize(p, TYPE, n)\n\n Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *\n sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return,\n *p* will be a pointer to the new memory area, or ``NULL`` in the event of\n failure.\n\n This is a C preprocessor macro; *p* is always reassigned. Save the original\n value of *p* to avoid losing memory when handling errors.\n\n\n.. c:function:: void PyMem_Del(void *p)\n\n Same as :c:func:`PyMem_Free`.\n\nIn addition, the following macro sets are provided for calling the Python memory\nallocator directly, without involving the C API functions listed above. However,\nnote that their use does not preserve binary compatibility across Python\nversions and is therefore deprecated in extension modules.\n\n* ``PyMem_MALLOC(size)``\n* ``PyMem_NEW(type, size)``\n* ``PyMem_REALLOC(ptr, size)``\n* ``PyMem_RESIZE(ptr, type, size)``\n* ``PyMem_FREE(ptr)``\n* ``PyMem_DEL(ptr)``\n\n\n"", ""Default Memory Allocators\n=========================\n\nDefault memory allocators:\n\n=============================== ==================== ================== ===================== ====================\nConfiguration Name PyMem_RawMalloc PyMem_Malloc PyObject_Malloc\n=============================== ==================== ================== ===================== ====================\nRelease build ``\""pymalloc\""`` ``malloc`` ``pymalloc`` ``pymalloc``\nDebug build ``\""pymalloc_debug\""`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug\nRelease build, without pymalloc ``\""malloc\""`` ``malloc`` ``malloc`` ``malloc``\nDebug build, without pymalloc ``\""malloc_debug\""`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug\n=============================== ==================== ================== ===================== ====================\n\nLegend:\n\n* Name: value for :envvar:`PYTHONMALLOC` environment variable.\n* ``malloc``: system allocators from the standard C library, C functions:\n :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.\n* ``pymalloc``: :ref:`pymalloc memory allocator `.\n* \""+ debug\"": with :ref:`debug hooks on the Python memory allocators\n `.\n* \""Debug build\"": :ref:`Python build in debug mode `.\n\n.. _customize-memory-allocators:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/c-api/memory.rst#codepoints:26143:29221"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-c-api-memory.rst-head2,dp-Python-c-api-memory.rst,Python 3.12.7 documentation: Memory Interface,"[""Memory Interface\n================\n\nThe following function sets, modeled after the ANSI C standard, but specifying\nbehavior when requesting zero bytes, are available for allocating and releasing\nmemory from the Python heap.\n\nThe :ref:`default memory allocator ` uses the\n:ref:`pymalloc memory allocator `.\n\n.. warning::\n\n The :term:`GIL ` must be held when using these\n functions.\n\n.. versionchanged:: 3.6\n\n The default allocator is now pymalloc instead of system :c:func:`malloc`.\n\n.. c:function:: void* PyMem_Malloc(size_t n)\n\n Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the\n allocated memory, or ``NULL`` if the request fails.\n\n Requesting zero bytes returns a distinct non-``NULL`` pointer if possible, as\n if ``PyMem_Malloc(1)`` had been called instead. The memory will not have\n been initialized in any way.\n\n\n.. c:function:: void* PyMem_Calloc(size_t nelem, size_t elsize)\n\n Allocates *nelem* elements each whose size in bytes is *elsize* and returns\n a pointer of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the\n request fails. The memory is initialized to zeros.\n\n Requesting zero elements or elements of size zero bytes returns a distinct\n non-``NULL`` pointer if possible, as if ``PyMem_Calloc(1, 1)`` had been called\n instead.\n\n .. versionadded:: 3.5\n\n\n.. c:function:: void* PyMem_Realloc(void *p, size_t n)\n\n Resizes the memory block pointed to by *p* to *n* bytes. The contents will be\n unchanged to the minimum of the old and the new sizes.\n\n If *p* is ``NULL``, the call is equivalent to ``PyMem_Malloc(n)``; else if *n*\n is equal to zero, the memory block is resized but is not freed, and the\n returned pointer is non-``NULL``.\n\n Unless *p* is ``NULL``, it must have been returned by a previous call to\n :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`.\n\n If the request fails, :c:func:`PyMem_Realloc` returns ``NULL`` and *p* remains\n a valid pointer to the previous memory area.\n\n\n.. c:function:: void PyMem_Free(void *p)\n\n Frees the memory block pointed to by *p*, which must have been returned by a\n previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or\n :c:func:`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been called\n before, undefined behavior occurs.\n\n If *p* is ``NULL``, no operation is performed.\n\nThe following type-oriented macros are provided for convenience. Note that\n*TYPE* refers to any C type.\n\n\n.. c:macro:: PyMem_New(TYPE, n)\n\n Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of\n memory. Returns a pointer cast to ``TYPE*``. The memory will not have\n been initialized in any way.\n\n\n.. c:macro:: PyMem_Resize(p, TYPE, n)\n\n Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *\n sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return,\n *p* will be a pointer to the new memory area, or ``NULL`` in the event of\n failure.\n\n This is a C preprocessor macro; *p* is always reassigned. Save the original\n value of *p* to avoid losing memory when handling errors.\n\n\n.. c:function:: void PyMem_Del(void *p)\n\n Same as :c:func:`PyMem_Free`.\n\nIn addition, the following macro sets are provided for calling the Python memory\nallocator directly, without involving the C API functions listed above. However,\nnote that their use does not preserve binary compatibility across Python\nversions and is therefore deprecated in extension modules.\n\n* ``PyMem_MALLOC(size)``\n* ``PyMem_NEW(type, size)``\n* ``PyMem_REALLOC(ptr, size)``\n* ``PyMem_RESIZE(ptr, type, size)``\n* ``PyMem_FREE(ptr)``\n* ``PyMem_DEL(ptr)``\n\n\n""]","[""Allocator Domains\n=================\n\n.. _allocator-domains:\n\nAll allocating functions belong to one of three different \""domains\"" (see also\n:c:type:`PyMemAllocatorDomain`). These domains represent different allocation\nstrategies and are optimized for different purposes. The specific details on\nhow every domain allocates memory or what internal functions each domain calls\nis considered an implementation detail, but for debugging purposes a simplified\ntable can be found at :ref:`here `. There is no hard\nrequirement to use the memory returned by the allocation functions belonging to\na given domain for only the purposes hinted by that domain (although this is the\nrecommended practice). For example, one could use the memory returned by\n:c:func:`PyMem_RawMalloc` for allocating Python objects or the memory returned\nby :c:func:`PyObject_Malloc` for allocating memory for buffers.\n\nThe three allocation domains are:\n\n* Raw domain: intended for allocating memory for general-purpose memory\n buffers where the allocation *must* go to the system allocator or where the\n allocator can operate without the :term:`GIL`. The memory is requested directly\n to the system.\n\n* \""Mem\"" domain: intended for allocating memory for Python buffers and\n general-purpose memory buffers where the allocation must be performed with\n the :term:`GIL` held. The memory is taken from the Python private heap.\n\n* Object domain: intended for allocating memory belonging to Python objects. The\n memory is taken from the Python private heap.\n\nWhen freeing memory previously allocated by the allocating functions belonging to a\ngiven domain,the matching specific deallocating functions must be used. For example,\n:c:func:`PyMem_Free` must be used to free memory allocated using :c:func:`PyMem_Malloc`.\n\n"", ""Default Memory Allocators\n=========================\n\nDefault memory allocators:\n\n=============================== ==================== ================== ===================== ====================\nConfiguration Name PyMem_RawMalloc PyMem_Malloc PyObject_Malloc\n=============================== ==================== ================== ===================== ====================\nRelease build ``\""pymalloc\""`` ``malloc`` ``pymalloc`` ``pymalloc``\nDebug build ``\""pymalloc_debug\""`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug\nRelease build, without pymalloc ``\""malloc\""`` ``malloc`` ``malloc`` ``malloc``\nDebug build, without pymalloc ``\""malloc_debug\""`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug\n=============================== ==================== ================== ===================== ====================\n\nLegend:\n\n* Name: value for :envvar:`PYTHONMALLOC` environment variable.\n* ``malloc``: system allocators from the standard C library, C functions:\n :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.\n* ``pymalloc``: :ref:`pymalloc memory allocator `.\n* \""+ debug\"": with :ref:`debug hooks on the Python memory allocators\n `.\n* \""Debug build\"": :ref:`Python build in debug mode `.\n\n.. _customize-memory-allocators:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/c-api/memory.rst#codepoints:8462:12192"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:c-api/memory.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-copyright.rst-head0,dp-Python-copyright.rst,Python 3.13.0 documentation: Copyright,"[""*********\nCopyright\n*********\n\nPython and this documentation is:\n\nCopyright © 2001-2024 Python Software Foundation. All rights reserved.\n\nCopyright © 2000 BeOpen.com. All rights reserved.\n\nCopyright © 1995-2000 Corporation for National Research Initiatives. All rights\nreserved.\n\nCopyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.\n\n-------\n\nSee :ref:`history-and-license` for complete license and permissions information.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/copyright.rst#codepoints:0:447"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:copyright.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-copyright.rst-head0,dp-Python-copyright.rst,Python 3.12.7 documentation: Copyright,"[""*********\nCopyright\n*********\n\nPython and this documentation is:\n\nCopyright © 2001-2023 Python Software Foundation. All rights reserved.\n\nCopyright © 2000 BeOpen.com. All rights reserved.\n\nCopyright © 1995-2000 Corporation for National Research Initiatives. All rights\nreserved.\n\nCopyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.\n\n-------\n\nSee :ref:`history-and-license` for complete license and permissions information.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/copyright.rst#codepoints:0:447"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:copyright.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-extending-index.rst-head0,dp-Python-extending-index.rst,Python 3.13.0 documentation: Creating extensions without third party tools,"["".. _extending-index:\n\n##################################################\n Extending and Embedding the Python Interpreter\n##################################################\n\nThis document describes how to write modules in C or C++ to extend the Python\ninterpreter with new modules. Those modules can not only define new functions\nbut also new object types and their methods. The document also describes how\nto embed the Python interpreter in another application, for use as an extension\nlanguage. Finally, it shows how to compile and link extension modules so that\nthey can be loaded dynamically (at run time) into the interpreter, if the\nunderlying operating system supports this feature.\n\nThis document assumes basic knowledge about Python. For an informal\nintroduction to the language, see :ref:`tutorial-index`. :ref:`reference-index`\ngives a more formal definition of the language. :ref:`library-index` documents\nthe existing object types, functions and modules (both built-in and written in\nPython) that give the language its wide application range.\n\nFor a detailed description of the whole Python/C API, see the separate\n:ref:`c-api-index`.\n\n\nRecommended third party tools\n=============================\n\nThis guide only covers the basic tools for creating extensions provided\nas part of this version of CPython. Third party tools like\n`Cython `_, `cffi `_,\n`SWIG `_ and `Numba `_\noffer both simpler and more sophisticated approaches to creating C and C++\nextensions for Python.\n\n.. seealso::\n\n `Python Packaging User Guide: Binary Extensions `_\n The Python Packaging User Guide not only covers several available\n tools that simplify the creation of binary extensions, but also\n discusses the various reasons why creating an extension module may be\n desirable in the first place.\n\n\nCreating extensions without third party tools\n=============================================\n\nThis section of the guide covers creating C and C++ extensions without\nassistance from third party tools. It is intended primarily for creators\nof those tools, rather than being a recommended way to create your own\nC extensions.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n extending.rst\n newtypes_tutorial.rst\n newtypes.rst\n building.rst\n windows.rst\n\nEmbedding the CPython runtime in a larger application\n=====================================================\n\nSometimes, rather than creating an extension that runs inside the Python\ninterpreter as the main application, it is desirable to instead embed\nthe CPython runtime inside a larger application. This section covers\nsome of the details involved in doing that successfully.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n embedding.rst\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/extending/index.rst#codepoints:0:2878"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:extending/index.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-extending-index.rst-head1,dp-Python-extending-index.rst,Python 3.13.0 documentation: Embedding the CPython runtime in a larger application,"["".. _extending-index:\n\n##################################################\n Extending and Embedding the Python Interpreter\n##################################################\n\nThis document describes how to write modules in C or C++ to extend the Python\ninterpreter with new modules. Those modules can not only define new functions\nbut also new object types and their methods. The document also describes how\nto embed the Python interpreter in another application, for use as an extension\nlanguage. Finally, it shows how to compile and link extension modules so that\nthey can be loaded dynamically (at run time) into the interpreter, if the\nunderlying operating system supports this feature.\n\nThis document assumes basic knowledge about Python. For an informal\nintroduction to the language, see :ref:`tutorial-index`. :ref:`reference-index`\ngives a more formal definition of the language. :ref:`library-index` documents\nthe existing object types, functions and modules (both built-in and written in\nPython) that give the language its wide application range.\n\nFor a detailed description of the whole Python/C API, see the separate\n:ref:`c-api-index`.\n\n\nRecommended third party tools\n=============================\n\nThis guide only covers the basic tools for creating extensions provided\nas part of this version of CPython. Third party tools like\n`Cython `_, `cffi `_,\n`SWIG `_ and `Numba `_\noffer both simpler and more sophisticated approaches to creating C and C++\nextensions for Python.\n\n.. seealso::\n\n `Python Packaging User Guide: Binary Extensions `_\n The Python Packaging User Guide not only covers several available\n tools that simplify the creation of binary extensions, but also\n discusses the various reasons why creating an extension module may be\n desirable in the first place.\n\n\nCreating extensions without third party tools\n=============================================\n\nThis section of the guide covers creating C and C++ extensions without\nassistance from third party tools. It is intended primarily for creators\nof those tools, rather than being a recommended way to create your own\nC extensions.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n extending.rst\n newtypes_tutorial.rst\n newtypes.rst\n building.rst\n windows.rst\n\nEmbedding the CPython runtime in a larger application\n=====================================================\n\nSometimes, rather than creating an extension that runs inside the Python\ninterpreter as the main application, it is desirable to instead embed\nthe CPython runtime inside a larger application. This section covers\nsome of the details involved in doing that successfully.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n embedding.rst\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/extending/index.rst#codepoints:0:2878"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:extending/index.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-extending-index.rst-head2,dp-Python-extending-index.rst,Python 3.13.0 documentation: Recommended third party tools,"["".. _extending-index:\n\n##################################################\n Extending and Embedding the Python Interpreter\n##################################################\n\nThis document describes how to write modules in C or C++ to extend the Python\ninterpreter with new modules. Those modules can not only define new functions\nbut also new object types and their methods. The document also describes how\nto embed the Python interpreter in another application, for use as an extension\nlanguage. Finally, it shows how to compile and link extension modules so that\nthey can be loaded dynamically (at run time) into the interpreter, if the\nunderlying operating system supports this feature.\n\nThis document assumes basic knowledge about Python. For an informal\nintroduction to the language, see :ref:`tutorial-index`. :ref:`reference-index`\ngives a more formal definition of the language. :ref:`library-index` documents\nthe existing object types, functions and modules (both built-in and written in\nPython) that give the language its wide application range.\n\nFor a detailed description of the whole Python/C API, see the separate\n:ref:`c-api-index`.\n\n\nRecommended third party tools\n=============================\n\nThis guide only covers the basic tools for creating extensions provided\nas part of this version of CPython. Third party tools like\n`Cython `_, `cffi `_,\n`SWIG `_ and `Numba `_\noffer both simpler and more sophisticated approaches to creating C and C++\nextensions for Python.\n\n.. seealso::\n\n `Python Packaging User Guide: Binary Extensions `_\n The Python Packaging User Guide not only covers several available\n tools that simplify the creation of binary extensions, but also\n discusses the various reasons why creating an extension module may be\n desirable in the first place.\n\n\nCreating extensions without third party tools\n=============================================\n\nThis section of the guide covers creating C and C++ extensions without\nassistance from third party tools. It is intended primarily for creators\nof those tools, rather than being a recommended way to create your own\nC extensions.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n extending.rst\n newtypes_tutorial.rst\n newtypes.rst\n building.rst\n windows.rst\n\nEmbedding the CPython runtime in a larger application\n=====================================================\n\nSometimes, rather than creating an extension that runs inside the Python\ninterpreter as the main application, it is desirable to instead embed\nthe CPython runtime inside a larger application. This section covers\nsome of the details involved in doing that successfully.\n\n.. toctree::\n :maxdepth: 2\n :numbered:\n\n embedding.rst\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/extending/index.rst#codepoints:0:2878"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:extending/index.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-glossary.rst-head0,dp-Python-glossary.rst,Python 3.13.0 documentation: Glossary,"[""********\nGlossary\n********\n\n.. if you add new entries, keep the alphabetical sorting!\n\n.. glossary::\n\n ``>>>``\n The default Python prompt of the :term:`interactive` shell. Often\n seen for code examples which can be executed interactively in the\n interpreter.\n\n ``...``\n Can refer to:\n\n * The default Python prompt of the :term:`interactive` shell when entering the\n code for an indented code block, when within a pair of matching left and\n right delimiters (parentheses, square brackets, curly braces or triple\n quotes), or after specifying a decorator.\n\n * The :const:`Ellipsis` built-in constant.\n\n abstract base class\n Abstract base classes complement :term:`duck-typing` by\n providing a way to define interfaces when other techniques like\n :func:`hasattr` would be clumsy or subtly wrong (for example with\n :ref:`magic methods `). ABCs introduce virtual\n subclasses, which are classes that don't inherit from a class but are\n still recognized by :func:`isinstance` and :func:`issubclass`; see the\n :mod:`abc` module documentation. Python comes with many built-in ABCs for\n data structures (in the :mod:`collections.abc` module), numbers (in the\n :mod:`numbers` module), streams (in the :mod:`io` module), import finders\n and loaders (in the :mod:`importlib.abc` module). You can create your own\n ABCs with the :mod:`abc` module.\n\n annotation\n A label associated with a variable, a class\n attribute or a function parameter or return value,\n used by convention as a :term:`type hint`.\n\n Annotations of local variables cannot be accessed at runtime, but\n annotations of global variables, class attributes, and functions\n are stored in the :attr:`__annotations__`\n special attribute of modules, classes, and functions,\n respectively.\n\n See :term:`variable annotation`, :term:`function annotation`, :pep:`484`\n and :pep:`526`, which describe this functionality.\n Also see :ref:`annotations-howto`\n for best practices on working with annotations.\n\n argument\n A value passed to a :term:`function` (or :term:`method`) when calling the\n function. There are two kinds of argument:\n\n * :dfn:`keyword argument`: an argument preceded by an identifier (e.g.\n ``name=``) in a function call or passed as a value in a dictionary\n preceded by ``**``. For example, ``3`` and ``5`` are both keyword\n arguments in the following calls to :func:`complex`::\n\n complex(real=3, imag=5)\n complex(**{'real': 3, 'imag': 5})\n\n * :dfn:`positional argument`: an argument that is not a keyword argument.\n Positional arguments can appear at the beginning of an argument list\n and/or be passed as elements of an :term:`iterable` preceded by ``*``.\n For example, ``3`` and ``5`` are both positional arguments in the\n following calls::\n\n complex(3, 5)\n complex(*(3, 5))\n\n Arguments are assigned to the named local variables in a function body.\n See the :ref:`calls` section for the rules governing this assignment.\n Syntactically, any expression can be used to represent an argument; the\n evaluated value is assigned to the local variable.\n\n See also the :term:`parameter` glossary entry, the FAQ question on\n :ref:`the difference between arguments and parameters\n `, and :pep:`362`.\n\n asynchronous context manager\n An object which controls the environment seen in an\n :keyword:`async with` statement by defining :meth:`~object.__aenter__` and\n :meth:`~object.__aexit__` methods. Introduced by :pep:`492`.\n\n""]","["" ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer `,\n :data:`sys.stdout.buffer `, and instances of\n :class:`io.BytesIO` and :class:`gzip.GzipFile`.\n\n See also :term:`text file` for a file object able to read and write\n :class:`str` objects.\n\n borrowed reference\n In Python's C API, a borrowed reference is a reference to an object,\n where the code using the object does not own the reference.\n It becomes a dangling\n pointer if the object is destroyed. For example, a garbage collection can\n remove the last :term:`strong reference` to the object and so destroy it.\n\n Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is\n recommended to convert it to a :term:`strong reference` in-place, except\n when the object cannot be destroyed before the last usage of the borrowed\n reference. The :c:func:`Py_NewRef` function can be used to create a new\n :term:`strong reference`.\n\n bytes-like object\n An object that supports the :ref:`bufferobjects` and can\n export a C-:term:`contiguous` buffer. This includes all :class:`bytes`,\n :class:`bytearray`, and :class:`array.array` objects, as well as many\n common :class:`memoryview` objects. Bytes-like objects can\n be used for various operations that work with binary data; these include\n compression, saving to a binary file, and sending over a socket.\n\n Some operations need the binary data to be mutable. The documentation\n often refers to these as \""read-write bytes-like objects\"". Example\n mutable buffer objects include :class:`bytearray` and a\n :class:`memoryview` of a :class:`bytearray`.\n Other operations require the binary data to be stored in\n immutable objects (\""read-only bytes-like objects\""); examples\n of these include :class:`bytes` and a :class:`memoryview`\n of a :class:`bytes` object.\n\n bytecode\n Python source code is compiled into bytecode, the internal representation\n of a Python program in the CPython interpreter. The bytecode is also\n cached in ``.pyc`` files so that executing the same file is\n faster the second time (recompilation from source to bytecode can be\n avoided). This \""intermediate language\"" is said to run on a\n :term:`virtual machine` that executes the machine code corresponding to\n each bytecode. Do note that bytecodes are not expected to work between\n different Python virtual machines, nor to be stable between Python\n releases.\n\n A list of bytecode instructions can be found in the documentation for\n :ref:`the dis module `.\n\n callable\n A callable is an object that can be called, possibly with a set\n of arguments (see :term:`argument`), with the following syntax::\n\n callable(argument1, argument2, argumentN)\n\n A :term:`function`, and by extension a :term:`method`, is a callable.\n An instance of a class that implements the :meth:`~object.__call__`\n method is also a callable.\n\n callback\n A subroutine function which is passed as an argument to be executed at\n some point in the future.\n\n class\n A template for creating user-defined objects. Class definitions\n normally contain method definitions which operate on instances of the\n class.\n\n class variable\n A variable defined in a class and intended to be modified only at\n class level (i.e., not in an instance of the class).\n\n"", "" normally contain method definitions which operate on instances of the\n class.\n\n class variable\n A variable defined in a class and intended to be modified only at\n class level (i.e., not in an instance of the class).\n\n complex number\n An extension of the familiar real number system in which all numbers are\n expressed as a sum of a real part and an imaginary part. Imaginary\n numbers are real multiples of the imaginary unit (the square root of\n ``-1``), often written ``i`` in mathematics or ``j`` in\n engineering. Python has built-in support for complex numbers, which are\n written with this latter notation; the imaginary part is written with a\n ``j`` suffix, e.g., ``3+1j``. To get access to complex equivalents of the\n :mod:`math` module, use :mod:`cmath`. Use of complex numbers is a fairly\n advanced mathematical feature. If you're not aware of a need for them,\n it's almost certain you can safely ignore them.\n\n context manager\n An object which controls the environment seen in a :keyword:`with`\n statement by defining :meth:`~object.__enter__` and :meth:`~object.__exit__` methods.\n See :pep:`343`.\n\n context variable\n A variable which can have different values depending on its context.\n This is similar to Thread-Local Storage in which each execution\n thread may have a different value for a variable. However, with context\n variables, there may be several contexts in one execution thread and the\n main usage for context variables is to keep track of variables in\n concurrent asynchronous tasks.\n See :mod:`contextvars`.\n\n contiguous\n .. index:: C-contiguous, Fortran contiguous\n\n A buffer is considered contiguous exactly if it is either\n *C-contiguous* or *Fortran contiguous*. Zero-dimensional buffers are\n C and Fortran contiguous. In one-dimensional arrays, the items\n must be laid out in memory next to each other, in order of\n increasing indexes starting from zero. In multidimensional\n C-contiguous arrays, the last index varies the fastest when\n visiting items in order of memory address. However, in\n Fortran contiguous arrays, the first index varies the fastest.\n\n coroutine\n Coroutines are a more generalized form of subroutines. Subroutines are\n entered at one point and exited at another point. Coroutines can be\n entered, exited, and resumed at many different points. They can be\n implemented with the :keyword:`async def` statement. See also\n :pep:`492`.\n\n coroutine function\n A function which returns a :term:`coroutine` object. A coroutine\n function may be defined with the :keyword:`async def` statement,\n and may contain :keyword:`await`, :keyword:`async for`, and\n :keyword:`async with` keywords. These were introduced\n by :pep:`492`.\n\n CPython\n The canonical implementation of the Python programming language, as\n distributed on `python.org `_. The term \""CPython\""\n is used when necessary to distinguish this implementation from others\n such as Jython or IronPython.\n\n decorator\n A function returning another function, usually applied as a function\n transformation using the ``@wrapper`` syntax. Common examples for\n decorators are :func:`classmethod` and :func:`staticmethod`.\n\n The decorator syntax is merely syntactic sugar, the following two\n function definitions are semantically equivalent::\n\n def f(arg):\n ...\n f = staticmethod(f)\n\n @staticmethod\n def f(arg):\n ...\n\n The same concept exists for classes, but is less commonly used there. See\n the documentation for :ref:`function definitions ` and\n :ref:`class definitions ` for more about decorators.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/glossary.rst#codepoints:15:3776"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:glossary.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-glossary.rst-head0,dp-Python-glossary.rst,Python 3.12.7 documentation: Glossary,"[""********\nGlossary\n********\n\n.. if you add new entries, keep the alphabetical sorting!\n\n.. glossary::\n\n ``>>>``\n The default Python prompt of the interactive shell. Often seen for code\n examples which can be executed interactively in the interpreter.\n\n ``...``\n Can refer to:\n\n * The default Python prompt of the interactive shell when entering the\n code for an indented code block, when within a pair of matching left and\n right delimiters (parentheses, square brackets, curly braces or triple\n quotes), or after specifying a decorator.\n\n * The :const:`Ellipsis` built-in constant.\n\n 2to3\n A tool that tries to convert Python 2.x code to Python 3.x code by\n handling most of the incompatibilities which can be detected by parsing the\n source and traversing the parse tree.\n\n 2to3 is available in the standard library as :mod:`lib2to3`; a standalone\n entry point is provided as :file:`Tools/scripts/2to3`. See\n :ref:`2to3-reference`.\n\n abstract base class\n Abstract base classes complement :term:`duck-typing` by\n providing a way to define interfaces when other techniques like\n :func:`hasattr` would be clumsy or subtly wrong (for example with\n :ref:`magic methods `). ABCs introduce virtual\n subclasses, which are classes that don't inherit from a class but are\n still recognized by :func:`isinstance` and :func:`issubclass`; see the\n :mod:`abc` module documentation. Python comes with many built-in ABCs for\n data structures (in the :mod:`collections.abc` module), numbers (in the\n :mod:`numbers` module), streams (in the :mod:`io` module), import finders\n and loaders (in the :mod:`importlib.abc` module). You can create your own\n ABCs with the :mod:`abc` module.\n\n annotation\n A label associated with a variable, a class\n attribute or a function parameter or return value,\n used by convention as a :term:`type hint`.\n\n Annotations of local variables cannot be accessed at runtime, but\n annotations of global variables, class attributes, and functions\n are stored in the :attr:`__annotations__`\n special attribute of modules, classes, and functions,\n respectively.\n\n See :term:`variable annotation`, :term:`function annotation`, :pep:`484`\n and :pep:`526`, which describe this functionality.\n Also see :ref:`annotations-howto`\n for best practices on working with annotations.\n\n argument\n A value passed to a :term:`function` (or :term:`method`) when calling the\n function. There are two kinds of argument:\n\n * :dfn:`keyword argument`: an argument preceded by an identifier (e.g.\n ``name=``) in a function call or passed as a value in a dictionary\n preceded by ``**``. For example, ``3`` and ``5`` are both keyword\n arguments in the following calls to :func:`complex`::\n\n complex(real=3, imag=5)\n complex(**{'real': 3, 'imag': 5})\n\n * :dfn:`positional argument`: an argument that is not a keyword argument.\n Positional arguments can appear at the beginning of an argument list\n and/or be passed as elements of an :term:`iterable` preceded by ``*``.\n For example, ``3`` and ``5`` are both positional arguments in the\n following calls::\n\n complex(3, 5)\n complex(*(3, 5))\n\n Arguments are assigned to the named local variables in a function body.\n See the :ref:`calls` section for the rules governing this assignment.\n Syntactically, any expression can be used to represent an argument; the\n evaluated value is assigned to the local variable.\n\n See also the :term:`parameter` glossary entry, the FAQ question on\n :ref:`the difference between arguments and parameters\n `, and :pep:`362`.\n\n""]","["" evaluated value is assigned to the local variable.\n\n See also the :term:`parameter` glossary entry, the FAQ question on\n :ref:`the difference between arguments and parameters\n `, and :pep:`362`.\n\n asynchronous context manager\n An object which controls the environment seen in an\n :keyword:`async with` statement by defining :meth:`~object.__aenter__` and\n :meth:`~object.__aexit__` methods. Introduced by :pep:`492`.\n\n asynchronous generator\n A function which returns an :term:`asynchronous generator iterator`. It\n looks like a coroutine function defined with :keyword:`async def` except\n that it contains :keyword:`yield` expressions for producing a series of\n values usable in an :keyword:`async for` loop.\n\n Usually refers to an asynchronous generator function, but may refer to an\n *asynchronous generator iterator* in some contexts. In cases where the\n intended meaning isn't clear, using the full terms avoids ambiguity.\n\n An asynchronous generator function may contain :keyword:`await`\n expressions as well as :keyword:`async for`, and :keyword:`async with`\n statements.\n\n asynchronous generator iterator\n An object created by a :term:`asynchronous generator` function.\n\n This is an :term:`asynchronous iterator` which when called using the\n :meth:`~object.__anext__` method returns an awaitable object which will execute\n the body of the asynchronous generator function until the next\n :keyword:`yield` expression.\n\n Each :keyword:`yield` temporarily suspends processing, remembering the\n location execution state (including local variables and pending\n try-statements). When the *asynchronous generator iterator* effectively\n resumes with another awaitable returned by :meth:`~object.__anext__`, it\n picks up where it left off. See :pep:`492` and :pep:`525`.\n\n asynchronous iterable\n An object, that can be used in an :keyword:`async for` statement.\n Must return an :term:`asynchronous iterator` from its\n :meth:`~object.__aiter__` method. Introduced by :pep:`492`.\n\n asynchronous iterator\n An object that implements the :meth:`~object.__aiter__` and :meth:`~object.__anext__`\n methods. :meth:`~object.__anext__` must return an :term:`awaitable` object.\n :keyword:`async for` resolves the awaitables returned by an asynchronous\n iterator's :meth:`~object.__anext__` method until it raises a\n :exc:`StopAsyncIteration` exception. Introduced by :pep:`492`.\n\n attribute\n A value associated with an object which is usually referenced by name\n using dotted expressions.\n For example, if an object *o* has an attribute\n *a* it would be referenced as *o.a*.\n\n It is possible to give an object an attribute whose name is not an\n identifier as defined by :ref:`identifiers`, for example using\n :func:`setattr`, if the object allows it.\n Such an attribute will not be accessible using a dotted expression,\n and would instead need to be retrieved with :func:`getattr`.\n\n awaitable\n An object that can be used in an :keyword:`await` expression. Can be\n a :term:`coroutine` or an object with an :meth:`~object.__await__` method.\n See also :pep:`492`.\n\n BDFL\n Benevolent Dictator For Life, a.k.a. `Guido van Rossum\n `_, Python's creator.\n\n binary file\n A :term:`file object` able to read and write\n :term:`bytes-like objects `.\n Examples of binary files are files opened in binary mode (``'rb'``,\n ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer `,\n :data:`sys.stdout.buffer `, and instances of\n :class:`io.BytesIO` and :class:`gzip.GzipFile`.\n\n See also :term:`text file` for a file object able to read and write\n :class:`str` objects.\n\n"", ""\n function\n A series of statements which returns some value to a caller. It can also\n be passed zero or more :term:`arguments ` which may be used in\n the execution of the body. See also :term:`parameter`, :term:`method`,\n and the :ref:`function` section.\n\n function annotation\n An :term:`annotation` of a function parameter or return value.\n\n Function annotations are usually used for\n :term:`type hints `: for example, this function is expected to take two\n :class:`int` arguments and is also expected to have an :class:`int`\n return value::\n\n def sum_two_numbers(a: int, b: int) -> int:\n return a + b\n\n Function annotation syntax is explained in section :ref:`function`.\n\n See :term:`variable annotation` and :pep:`484`,\n which describe this functionality.\n Also see :ref:`annotations-howto`\n for best practices on working with annotations.\n\n __future__\n A :ref:`future statement `, ``from __future__ import ``,\n directs the compiler to compile the current module using syntax or\n semantics that will become standard in a future release of Python.\n The :mod:`__future__` module documents the possible values of\n *feature*. By importing this module and evaluating its variables,\n you can see when a new feature was first added to the language and\n when it will (or did) become the default::\n\n >>> import __future__\n >>> __future__.division\n _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)\n\n garbage collection\n The process of freeing memory when it is not used anymore. Python\n performs garbage collection via reference counting and a cyclic garbage\n collector that is able to detect and break reference cycles. The\n garbage collector can be controlled using the :mod:`gc` module.\n\n .. index:: single: generator\n\n generator\n A function which returns a :term:`generator iterator`. It looks like a\n normal function except that it contains :keyword:`yield` expressions\n for producing a series of values usable in a for-loop or that can be\n retrieved one at a time with the :func:`next` function.\n\n Usually refers to a generator function, but may refer to a\n *generator iterator* in some contexts. In cases where the intended\n meaning isn't clear, using the full terms avoids ambiguity.\n\n generator iterator\n An object created by a :term:`generator` function.\n\n Each :keyword:`yield` temporarily suspends processing, remembering the\n location execution state (including local variables and pending\n try-statements). When the *generator iterator* resumes, it picks up where\n it left off (in contrast to functions which start fresh on every\n invocation).\n\n .. index:: single: generator expression\n\n generator expression\n An expression that returns an iterator. It looks like a normal expression\n followed by a :keyword:`!for` clause defining a loop variable, range,\n and an optional :keyword:`!if` clause. The combined expression\n generates values for an enclosing function::\n\n >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n 285\n\n generic function\n A function composed of multiple functions implementing the same operation\n for different types. Which implementation should be used during a call is\n determined by the dispatch algorithm.\n\n See also the :term:`single dispatch` glossary entry, the\n :func:`functools.singledispatch` decorator, and :pep:`443`.\n\n generic type\n A :term:`type` that can be parameterized; typically a\n :ref:`container class` such as :class:`list` or\n :class:`dict`. Used for :term:`type hints ` and\n :term:`annotations `.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/glossary.rst#codepoints:15:3898"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:glossary.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-howto-clinic.rst-head0,dp-Python-howto-clinic.rst,Python 3.13.0 documentation: Argument Clinic How-To,"["":orphan:\n\n.. This page is retained solely for existing links to /howto/clinic.html.\n Direct readers to the devguide.\n\n**********************\nArgument Clinic How-To\n**********************\n\n\n.. note::\n\n The Argument Clinic How-TO has been moved to the `Python Developer's Guide\n `__.\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/clinic.rst#codepoints:0:343"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/clinic.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-howto-cporting.rst-head0,dp-Python-howto-cporting.rst,Python 3.13.0 documentation: Porting Extension Modules to Python 3,"["".. highlight:: c\n\n.. _cporting-howto:\n\n*************************************\nPorting Extension Modules to Python 3\n*************************************\n\nWe recommend the following resources for porting extension modules to Python 3:\n\n* The `Migrating C extensions`_ chapter from\n *Supporting Python 3: An in-depth guide*, a book on moving from Python 2\n to Python 3 in general, guides the reader through porting an extension\n module.\n* The `Porting guide`_ from the *py3c* project provides opinionated\n suggestions with supporting code.\n* The `Cython`_ and `CFFI`_ libraries offer abstractions over\n Python's C API.\n Extensions generally need to be re-written to use one of them,\n but the library then handles differences between various Python\n versions and implementations.\n\n.. _Migrating C extensions: http://python3porting.com/cextensions.html\n.. _Porting guide: https://py3c.readthedocs.io/en/latest/guide.html\n.. _Cython: https://cython.org/\n.. _CFFI: https://cffi.readthedocs.io/en/latest/\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/cporting.rst#codepoints:0:1006"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/cporting.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-howto-perf_profiling.rst-head0,dp-Python-howto-perf_profiling.rst,Python 3.13.0 documentation: How to obtain the best results,"[""How to enable ``perf`` profiling support\n----------------------------------------\n\n``perf`` profiling support can be enabled either from the start using\nthe environment variable :envvar:`PYTHONPERFSUPPORT` or the\n:option:`-X perf <-X>` option,\nor dynamically using :func:`sys.activate_stack_trampoline` and\n:func:`sys.deactivate_stack_trampoline`.\n\nThe :mod:`!sys` functions take precedence over the :option:`!-X` option,\nthe :option:`!-X` option takes precedence over the environment variable.\n\nExample, using the environment variable::\n\n $ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python script.py\n $ perf report -g -i perf.data\n\nExample, using the :option:`!-X` option::\n\n $ perf record -F 9999 -g -o perf.data python -X perf script.py\n $ perf report -g -i perf.data\n\nExample, using the :mod:`sys` APIs in file :file:`example.py`:\n\n.. code-block:: python\n\n import sys\n\n sys.activate_stack_trampoline(\""perf\"")\n do_profiled_stuff()\n sys.deactivate_stack_trampoline()\n\n non_profiled_stuff()\n\n...then::\n\n $ perf record -F 9999 -g -o perf.data python ./example.py\n $ perf report -g -i perf.data\n\n\nHow to obtain the best results\n------------------------------\n\nFor best results, Python should be compiled with\n``CFLAGS=\""-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer\""`` as this allows\nprofilers to unwind using only the frame pointer and not on DWARF debug\ninformation. This is because as the code that is interposed to allow ``perf``\nsupport is dynamically generated it doesn't have any DWARF debugging information\navailable.\n\nYou can check if your system has been compiled with this flag by running::\n\n $ python -m sysconfig | grep 'no-omit-frame-pointer'\n\nIf you don't see any output it means that your interpreter has not been compiled with\nframe pointers and therefore it may not be able to show Python functions in the output\nof ``perf``.\n\n\n""]","[""==============================================\nPython support for the Linux ``perf`` profiler\n==============================================\n\n:author: Pablo Galindo\n\n`The Linux perf profiler `_\nis a very powerful tool that allows you to profile and obtain\ninformation about the performance of your application.\n``perf`` also has a very vibrant ecosystem of tools\nthat aid with the analysis of the data that it produces.\n\nThe main problem with using the ``perf`` profiler with Python applications is that\n``perf`` only gets information about native symbols, that is, the names of\nfunctions and procedures written in C. This means that the names and file names\nof Python functions in your code will not appear in the output of ``perf``.\n\nSince Python 3.12, the interpreter can run in a special mode that allows Python\nfunctions to appear in the output of the ``perf`` profiler. When this mode is\nenabled, the interpreter will interpose a small piece of code compiled on the\nfly before the execution of every Python function and it will teach ``perf`` the\nrelationship between this piece of code and the associated Python function using\n:doc:`perf map files <../c-api/perfmaps>`.\n\n.. note::\n\n Support for the ``perf`` profiler is currently only available for Linux on\n select architectures. Check the output of the ``configure`` build step or\n check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE``\n to see if your system is supported.\n\nFor example, consider the following script:\n\n.. code-block:: python\n\n def foo(n):\n result = 0\n for _ in range(n):\n result += 1\n return result\n\n def bar(n):\n foo(n)\n\n def baz(n):\n bar(n)\n\n if __name__ == \""__main__\"":\n baz(1000000)\n\nWe can run ``perf`` to sample CPU stack traces at 9999 hertz::\n\n $ perf record -F 9999 -g -o perf.data python my_script.py\n\nThen we can use ``perf report`` to analyze the data:\n\n.. code-block:: shell-session\n\n $ perf report --stdio -n -g\n\n # Children Self Samples Command Shared Object Symbol\n # ........ ........ ............ .......... .................. ..........................................\n #\n 91.08% 0.00% 0 python.exe python.exe [.] _start\n |\n ---_start\n |\n --90.71%--__libc_start_main\n Py_BytesMain\n |\n |--56.88%--pymain_run_python.constprop.0\n | |\n | |--56.13%--_PyRun_AnyFileObject\n | | _PyRun_SimpleFileObject\n | | |\n | | |--55.02%--run_mod\n | | | |\n | | | --54.65%--PyEval_EvalCode\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | |\n | | | |--51.67%--_PyEval_EvalFrameDefault\n | | | | |\n | | | | |--11.52%--_PyLong_Add\n | | | | | |\n | | | | | |--2.97%--_PyObject_Malloc\n ...\n\nAs you can see, the Python functions are not shown in the output, only ``_PyEval_EvalFrameDefault``\n(the function that evaluates the Python bytecode) shows up. Unfortunately that's not very useful because all Python\nfunctions use the same C function to evaluate bytecode so we cannot know which Python function corresponds to which\nbytecode-evaluating function.\n\nInstead, if we run the same experiment with ``perf`` support enabled we get:\n\n.. code-block:: shell-session\n\n $ perf report --stdio -n -g\n\n # Children Self Samples Command Shared Object Symbol\n # ........ ........ ............ .......... .................. .....................................................................\n #\n 90.58% 0.36% 1 python.exe python.exe [.] _start\n |\n ---_start\n |\n --89.86%--__libc_start_main\n Py_BytesMain\n |\n |--55.43%--pymain_run_python.constprop.0\n | |\n | |--54.71%--_PyRun_AnyFileObject\n | | _PyRun_SimpleFileObject\n | | |\n | | |--53.62%--run_mod\n | | | |\n | | | --53.26%--PyEval_EvalCode\n | | | py:::/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::baz:/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::bar:/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::foo:/src/script.py\n | | | |\n | | | |--51.81%--_PyEval_EvalFrameDefault\n | | | | |\n | | | | |--13.77%--_PyLong_Add\n | | | | | |\n | | | | | |--3.26%--_PyObject_Malloc\n\n\n\n"", ""How to work without frame pointers\n----------------------------------\n\nIf you are working with a Python interpreter that has been compiled without\nframe pointers, you can still use the ``perf`` profiler, but the overhead will be\na bit higher because Python needs to generate unwinding information for every\nPython function call on the fly. Additionally, ``perf`` will take more time to\nprocess the data because it will need to use the DWARF debugging information to\nunwind the stack and this is a slow process.\n\nTo enable this mode, you can use the environment variable\n:envvar:`PYTHON_PERF_JIT_SUPPORT` or the :option:`-X perf_jit <-X>` option,\nwhich will enable the JIT mode for the ``perf`` profiler.\n\n.. note::\n\n Due to a bug in the ``perf`` tool, only ``perf`` versions higher than v6.8\n will work with the JIT mode. The fix was also backported to the v6.7.2\n version of the tool.\n\n Note that when checking the version of the ``perf`` tool (which can be done\n by running ``perf version``) you must take into account that some distros\n add some custom version numbers including a ``-`` character. This means\n that ``perf 6.7-3`` is not necessarily ``perf 6.7.3``.\n\nWhen using the perf JIT mode, you need an extra step before you can run ``perf\nreport``. You need to call the ``perf inject`` command to inject the JIT\ninformation into the ``perf.data`` file.::\n\n $ perf record -F 9999 -g --call-graph dwarf -o perf.data python -Xperf_jit my_script.py\n $ perf inject -i perf.data --jit --output perf.jit.data\n $ perf report -g -i perf.jit.data\n\nor using the environment variable::\n\n $ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o perf.data python my_script.py\n $ perf inject -i perf.data --jit --output perf.jit.data\n $ perf report -g -i perf.jit.data\n\n``perf inject --jit`` command will read ``perf.data``,\nautomatically pick up the perf dump file that Python creates (in\n``/tmp/perf-$PID.dump``), and then create ``perf.jit.data`` which merges all the\nJIT information together. It should also create a lot of ``jitted-XXXX-N.so``\nfiles in the current directory which are ELF images for all the JIT trampolines\nthat were created by Python.\n\n.. warning::\n Notice that when using ``--call-graph dwarf`` the ``perf`` tool will take\n snapshots of the stack of the process being profiled and save the\n information in the ``perf.data`` file. By default the size of the stack dump\n is 8192 bytes but the user can change the size by passing the size after\n comma like ``--call-graph dwarf,4096``. The size of the stack dump is\n important because if the size is too small ``perf`` will not be able to\n unwind the stack and the output will be incomplete. On the other hand, if\n the size is too big, then ``perf`` won't be able to sample the process as\n frequently as it would like as the overhead will be higher.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/perf_profiling.rst#codepoints:7831:9720"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/perf_profiling.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-howto-perf_profiling.rst-head1,dp-Python-howto-perf_profiling.rst,Python 3.13.0 documentation: How to work without frame pointers,"[""How to work without frame pointers\n----------------------------------\n\nIf you are working with a Python interpreter that has been compiled without\nframe pointers, you can still use the ``perf`` profiler, but the overhead will be\na bit higher because Python needs to generate unwinding information for every\nPython function call on the fly. Additionally, ``perf`` will take more time to\nprocess the data because it will need to use the DWARF debugging information to\nunwind the stack and this is a slow process.\n\nTo enable this mode, you can use the environment variable\n:envvar:`PYTHON_PERF_JIT_SUPPORT` or the :option:`-X perf_jit <-X>` option,\nwhich will enable the JIT mode for the ``perf`` profiler.\n\n.. note::\n\n Due to a bug in the ``perf`` tool, only ``perf`` versions higher than v6.8\n will work with the JIT mode. The fix was also backported to the v6.7.2\n version of the tool.\n\n Note that when checking the version of the ``perf`` tool (which can be done\n by running ``perf version``) you must take into account that some distros\n add some custom version numbers including a ``-`` character. This means\n that ``perf 6.7-3`` is not necessarily ``perf 6.7.3``.\n\nWhen using the perf JIT mode, you need an extra step before you can run ``perf\nreport``. You need to call the ``perf inject`` command to inject the JIT\ninformation into the ``perf.data`` file.::\n\n $ perf record -F 9999 -g --call-graph dwarf -o perf.data python -Xperf_jit my_script.py\n $ perf inject -i perf.data --jit --output perf.jit.data\n $ perf report -g -i perf.jit.data\n\nor using the environment variable::\n\n $ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o perf.data python my_script.py\n $ perf inject -i perf.data --jit --output perf.jit.data\n $ perf report -g -i perf.jit.data\n\n``perf inject --jit`` command will read ``perf.data``,\nautomatically pick up the perf dump file that Python creates (in\n``/tmp/perf-$PID.dump``), and then create ``perf.jit.data`` which merges all the\nJIT information together. It should also create a lot of ``jitted-XXXX-N.so``\nfiles in the current directory which are ELF images for all the JIT trampolines\nthat were created by Python.\n\n.. warning::\n Notice that when using ``--call-graph dwarf`` the ``perf`` tool will take\n snapshots of the stack of the process being profiled and save the\n information in the ``perf.data`` file. By default the size of the stack dump\n is 8192 bytes but the user can change the size by passing the size after\n comma like ``--call-graph dwarf,4096``. The size of the stack dump is\n important because if the size is too small ``perf`` will not be able to\n unwind the stack and the output will be incomplete. On the other hand, if\n the size is too big, then ``perf`` won't be able to sample the process as\n frequently as it would like as the overhead will be higher.\n\n""]","[""How to enable ``perf`` profiling support\n----------------------------------------\n\n``perf`` profiling support can be enabled either from the start using\nthe environment variable :envvar:`PYTHONPERFSUPPORT` or the\n:option:`-X perf <-X>` option,\nor dynamically using :func:`sys.activate_stack_trampoline` and\n:func:`sys.deactivate_stack_trampoline`.\n\nThe :mod:`!sys` functions take precedence over the :option:`!-X` option,\nthe :option:`!-X` option takes precedence over the environment variable.\n\nExample, using the environment variable::\n\n $ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python script.py\n $ perf report -g -i perf.data\n\nExample, using the :option:`!-X` option::\n\n $ perf record -F 9999 -g -o perf.data python -X perf script.py\n $ perf report -g -i perf.data\n\nExample, using the :mod:`sys` APIs in file :file:`example.py`:\n\n.. code-block:: python\n\n import sys\n\n sys.activate_stack_trampoline(\""perf\"")\n do_profiled_stuff()\n sys.deactivate_stack_trampoline()\n\n non_profiled_stuff()\n\n...then::\n\n $ perf record -F 9999 -g -o perf.data python ./example.py\n $ perf report -g -i perf.data\n\n\nHow to obtain the best results\n------------------------------\n\nFor best results, Python should be compiled with\n``CFLAGS=\""-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer\""`` as this allows\nprofilers to unwind using only the frame pointer and not on DWARF debug\ninformation. This is because as the code that is interposed to allow ``perf``\nsupport is dynamically generated it doesn't have any DWARF debugging information\navailable.\n\nYou can check if your system has been compiled with this flag by running::\n\n $ python -m sysconfig | grep 'no-omit-frame-pointer'\n\nIf you don't see any output it means that your interpreter has not been compiled with\nframe pointers and therefore it may not be able to show Python functions in the output\nof ``perf``.\n\n\n"", ""==============================================\nPython support for the Linux ``perf`` profiler\n==============================================\n\n:author: Pablo Galindo\n\n`The Linux perf profiler `_\nis a very powerful tool that allows you to profile and obtain\ninformation about the performance of your application.\n``perf`` also has a very vibrant ecosystem of tools\nthat aid with the analysis of the data that it produces.\n\nThe main problem with using the ``perf`` profiler with Python applications is that\n``perf`` only gets information about native symbols, that is, the names of\nfunctions and procedures written in C. This means that the names and file names\nof Python functions in your code will not appear in the output of ``perf``.\n\nSince Python 3.12, the interpreter can run in a special mode that allows Python\nfunctions to appear in the output of the ``perf`` profiler. When this mode is\nenabled, the interpreter will interpose a small piece of code compiled on the\nfly before the execution of every Python function and it will teach ``perf`` the\nrelationship between this piece of code and the associated Python function using\n:doc:`perf map files <../c-api/perfmaps>`.\n\n.. note::\n\n Support for the ``perf`` profiler is currently only available for Linux on\n select architectures. Check the output of the ``configure`` build step or\n check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE``\n to see if your system is supported.\n\nFor example, consider the following script:\n\n.. code-block:: python\n\n def foo(n):\n result = 0\n for _ in range(n):\n result += 1\n return result\n\n def bar(n):\n foo(n)\n\n def baz(n):\n bar(n)\n\n if __name__ == \""__main__\"":\n baz(1000000)\n\nWe can run ``perf`` to sample CPU stack traces at 9999 hertz::\n\n $ perf record -F 9999 -g -o perf.data python my_script.py\n\nThen we can use ``perf report`` to analyze the data:\n\n.. code-block:: shell-session\n\n $ perf report --stdio -n -g\n\n # Children Self Samples Command Shared Object Symbol\n # ........ ........ ............ .......... .................. ..........................................\n #\n 91.08% 0.00% 0 python.exe python.exe [.] _start\n |\n ---_start\n |\n --90.71%--__libc_start_main\n Py_BytesMain\n |\n |--56.88%--pymain_run_python.constprop.0\n | |\n | |--56.13%--_PyRun_AnyFileObject\n | | _PyRun_SimpleFileObject\n | | |\n | | |--55.02%--run_mod\n | | | |\n | | | --54.65%--PyEval_EvalCode\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | |\n | | | |--51.67%--_PyEval_EvalFrameDefault\n | | | | |\n | | | | |--11.52%--_PyLong_Add\n | | | | | |\n | | | | | |--2.97%--_PyObject_Malloc\n ...\n\nAs you can see, the Python functions are not shown in the output, only ``_PyEval_EvalFrameDefault``\n(the function that evaluates the Python bytecode) shows up. Unfortunately that's not very useful because all Python\nfunctions use the same C function to evaluate bytecode so we cannot know which Python function corresponds to which\nbytecode-evaluating function.\n\nInstead, if we run the same experiment with ``perf`` support enabled we get:\n\n.. code-block:: shell-session\n\n $ perf report --stdio -n -g\n\n # Children Self Samples Command Shared Object Symbol\n # ........ ........ ............ .......... .................. .....................................................................\n #\n 90.58% 0.36% 1 python.exe python.exe [.] _start\n |\n ---_start\n |\n --89.86%--__libc_start_main\n Py_BytesMain\n |\n |--55.43%--pymain_run_python.constprop.0\n | |\n | |--54.71%--_PyRun_AnyFileObject\n | | _PyRun_SimpleFileObject\n | | |\n | | |--53.62%--run_mod\n | | | |\n | | | --53.26%--PyEval_EvalCode\n | | | py:::/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::baz:/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::bar:/src/script.py\n | | | _PyEval_EvalFrameDefault\n | | | PyObject_Vectorcall\n | | | _PyEval_Vector\n | | | py::foo:/src/script.py\n | | | |\n | | | |--51.81%--_PyEval_EvalFrameDefault\n | | | | |\n | | | | |--13.77%--_PyLong_Add\n | | | | | |\n | | | | | |--3.26%--_PyObject_Malloc\n\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/perf_profiling.rst#codepoints:9720:12621"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/perf_profiling.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-howto-perf_profiling.rst-head0,dp-Python-howto-perf_profiling.rst,Python 3.12.7 documentation: How to obtain the best results,"[""How to enable ``perf`` profiling support\n----------------------------------------\n\n``perf`` profiling support can be enabled either from the start using\nthe environment variable :envvar:`PYTHONPERFSUPPORT` or the\n:option:`-X perf <-X>` option,\nor dynamically using :func:`sys.activate_stack_trampoline` and\n:func:`sys.deactivate_stack_trampoline`.\n\nThe :mod:`!sys` functions take precedence over the :option:`!-X` option,\nthe :option:`!-X` option takes precedence over the environment variable.\n\nExample, using the environment variable::\n\n $ PYTHONPERFSUPPORT=1 python script.py\n $ perf report -g -i perf.data\n\nExample, using the :option:`!-X` option::\n\n $ python -X perf script.py\n $ perf report -g -i perf.data\n\nExample, using the :mod:`sys` APIs in file :file:`example.py`:\n\n.. code-block:: python\n\n import sys\n\n sys.activate_stack_trampoline(\""perf\"")\n do_profiled_stuff()\n sys.deactivate_stack_trampoline()\n\n non_profiled_stuff()\n\n...then::\n\n $ python ./example.py\n $ perf report -g -i perf.data\n\n\nHow to obtain the best results\n------------------------------\n\nFor best results, Python should be compiled with\n``CFLAGS=\""-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer\""`` as this allows\nprofilers to unwind using only the frame pointer and not on DWARF debug\ninformation. This is because as the code that is interposed to allow ``perf``\nsupport is dynamically generated it doesn't have any DWARF debugging information\navailable.\n\nYou can check if your system has been compiled with this flag by running::\n\n $ python -m sysconfig | grep 'no-omit-frame-pointer'\n\nIf you don't see any output it means that your interpreter has not been compiled with\nframe pointers and therefore it may not be able to show Python functions in the output\nof ``perf``.\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/howto/perf_profiling.rst#codepoints:7831:9610"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:howto/perf_profiling.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-howto-sockets.rst-head0,dp-Python-howto-sockets.rst,Python 3.13.0 documentation: Using a Socket,"[""Using a Socket\n==============\n\nThe first thing to note, is that the web browser's \""client\"" socket and the web\nserver's \""client\"" socket are identical beasts. That is, this is a \""peer to peer\""\nconversation. Or to put it another way, *as the designer, you will have to\ndecide what the rules of etiquette are for a conversation*. Normally, the\n``connect``\\ ing socket starts the conversation, by sending in a request, or\nperhaps a signon. But that's a design decision - it's not a rule of sockets.\n\nNow there are two sets of verbs to use for communication. You can use ``send``\nand ``recv``, or you can transform your client socket into a file-like beast and\nuse ``read`` and ``write``. The latter is the way Java presents its sockets.\nI'm not going to talk about it here, except to warn you that you need to use\n``flush`` on sockets. These are buffered \""files\"", and a common mistake is to\n``write`` something, and then ``read`` for a reply. Without a ``flush`` in\nthere, you may wait forever for the reply, because the request may still be in\nyour output buffer.\n\nNow we come to the major stumbling block of sockets - ``send`` and ``recv`` operate\non the network buffers. They do not necessarily handle all the bytes you hand\nthem (or expect from them), because their major focus is handling the network\nbuffers. In general, they return when the associated network buffers have been\nfilled (``send``) or emptied (``recv``). They then tell you how many bytes they\nhandled. It is *your* responsibility to call them again until your message has\nbeen completely dealt with.\n\nWhen a ``recv`` returns 0 bytes, it means the other side has closed (or is in\nthe process of closing) the connection. You will not receive any more data on\nthis connection. Ever. You may be able to send data successfully; I'll talk\nmore about this later.\n\nA protocol like HTTP uses a socket for only one transfer. The client sends a\nrequest, then reads a reply. That's it. The socket is discarded. This means that\na client can detect the end of the reply by receiving 0 bytes.\n\nBut if you plan to reuse your socket for further transfers, you need to realize\nthat *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I repeat: if a socket\n``send`` or ``recv`` returns after handling 0 bytes, the connection has been\nbroken. If the connection has *not* been broken, you may wait on a ``recv``\nforever, because the socket will *not* tell you that there's nothing more to\nread (for now). Now if you think about that a bit, you'll come to realize a\nfundamental truth of sockets: *messages must either be fixed length* (yuck), *or\nbe delimited* (shrug), *or indicate how long they are* (much better), *or end by\nshutting down the connection*. The choice is entirely yours, (but some ways are\nrighter than others).\n\nAssuming you don't want to end the connection, the simplest solution is a fixed\nlength message::\n\n class MySocket:\n \""\""\""demonstration class only\n - coded for clarity, not efficiency\n \""\""\""\n\n def __init__(self, sock=None):\n if sock is None:\n self.sock = socket.socket(\n socket.AF_INET, socket.SOCK_STREAM)\n else:\n self.sock = sock\n\n def connect(self, host, port):\n self.sock.connect((host, port))\n\n def mysend(self, msg):\n totalsent = 0\n while totalsent < MSGLEN:\n sent = self.sock.send(msg[totalsent:])\n if sent == 0:\n raise RuntimeError(\""socket connection broken\"")\n totalsent = totalsent + sent\n\n def myreceive(self):\n chunks = []\n bytes_recd = 0\n while bytes_recd < MSGLEN:\n chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))\n if chunk == b'':\n raise RuntimeError(\""socket connection broken\"")\n chunks.append(chunk)\n bytes_recd = bytes_recd + len(chunk)\n return b''.join(chunks)\n\nThe sending code here is usable for almost any messaging scheme - in Python you\nsend strings, and you can use ``len()`` to determine its length (even if it has\nembedded ``\\0`` characters). It's mostly the receiving code that gets more\ncomplex. (And in C, it's not much worse, except you can't use ``strlen`` if the\nmessage has embedded ``\\0``\\ s.)\n\nThe easiest enhancement is to make the first character of the message an\nindicator of message type, and have the type determine the length. Now you have\ntwo ``recv``\\ s - the first to get (at least) that first character so you can\nlook up the length, and the second in a loop to get the rest. If you decide to\ngo the delimited route, you'll be receiving in some arbitrary chunk size, (4096\nor 8192 is frequently a good match for network buffer sizes), and scanning what\nyou've received for a delimiter.\n\nOne complication to be aware of: if your conversational protocol allows multiple\nmessages to be sent back to back (without some kind of reply), and you pass\n``recv`` an arbitrary chunk size, you may end up reading the start of a\nfollowing message. You'll need to put that aside and hold onto it, until it's\nneeded.\n\nPrefixing the message with its length (say, as 5 numeric characters) gets more\ncomplex, because (believe it or not), you may not get all 5 characters in one\n``recv``. In playing around, you'll get away with it; but in high network loads,\nyour code will very quickly break unless you use two ``recv`` loops - the first\nto determine the length, the second to get the data part of the message. Nasty.\nThis is also when you'll discover that ``send`` does not always manage to get\nrid of everything in one pass. And despite having read this, you will eventually\nget bit by it!\n\nIn the interests of space, building your character, (and preserving my\ncompetitive position), these enhancements are left as an exercise for the\nreader. Lets move on to cleaning up.\n\n\n""]","[""Creating a Socket\n=================\n\nRoughly speaking, when you clicked on the link that brought you to this page,\nyour browser did something like the following::\n\n # create an INET, STREAMing socket\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # now connect to the web server on port 80 - the normal http port\n s.connect((\""www.python.org\"", 80))\n\nWhen the ``connect`` completes, the socket ``s`` can be used to send\nin a request for the text of the page. The same socket will read the\nreply, and then be destroyed. That's right, destroyed. Client sockets\nare normally only used for one exchange (or a small set of sequential\nexchanges).\n\nWhat happens in the web server is a bit more complex. First, the web server\ncreates a \""server socket\""::\n\n # create an INET, STREAMing socket\n serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # bind the socket to a public host, and a well-known port\n serversocket.bind((socket.gethostname(), 80))\n # become a server socket\n serversocket.listen(5)\n\nA couple things to notice: we used ``socket.gethostname()`` so that the socket\nwould be visible to the outside world. If we had used ``s.bind(('localhost',\n80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a \""server\"" socket,\nbut one that was only visible within the same machine. ``s.bind(('', 80))``\nspecifies that the socket is reachable by any address the machine happens to\nhave.\n\nA second thing to note: low number ports are usually reserved for \""well known\""\nservices (HTTP, SNMP etc). If you're playing around, use a nice high number (4\ndigits).\n\nFinally, the argument to ``listen`` tells the socket library that we want it to\nqueue up as many as 5 connect requests (the normal max) before refusing outside\nconnections. If the rest of the code is written properly, that should be plenty.\n\nNow that we have a \""server\"" socket, listening on port 80, we can enter the\nmainloop of the web server::\n\n while True:\n # accept connections from outside\n (clientsocket, address) = serversocket.accept()\n # now do something with the clientsocket\n # in this case, we'll pretend this is a threaded server\n ct = client_thread(clientsocket)\n ct.run()\n\nThere's actually 3 general ways in which this loop could work - dispatching a\nthread to handle ``clientsocket``, create a new process to handle\n``clientsocket``, or restructure this app to use non-blocking sockets, and\nmultiplex between our \""server\"" socket and any active ``clientsocket``\\ s using\n``select``. More about that later. The important thing to understand now is\nthis: this is *all* a \""server\"" socket does. It doesn't send any data. It doesn't\nreceive any data. It just produces \""client\"" sockets. Each ``clientsocket`` is\ncreated in response to some *other* \""client\"" socket doing a ``connect()`` to the\nhost and port we're bound to. As soon as we've created that ``clientsocket``, we\ngo back to listening for more connections. The two \""clients\"" are free to chat it\nup - they are using some dynamically allocated port which will be recycled when\nthe conversation ends.\n\n\nIPC\n---\n\nIf you need fast IPC between two processes on one machine, you should look into\npipes or shared memory. If you do decide to use AF_INET sockets, bind the\n\""server\"" socket to ``'localhost'``. On most platforms, this will take a\nshortcut around a couple of layers of network code and be quite a bit faster.\n\n.. seealso::\n The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level\n API.\n\n\n"", ""Binary Data\n-----------\n\nIt is perfectly possible to send binary data over a socket. The major problem is\nthat not all machines use the same formats for binary data. For example,\n`network byte order `_\nis big-endian, with the most significant byte first,\nso a 16 bit integer with the value ``1`` would be the two hex bytes ``00 01``.\nHowever, most common processors (x86/AMD64, ARM, RISC-V), are little-endian,\nwith the least significant byte first - that same ``1`` would be ``01 00``.\n\nSocket libraries have calls for converting 16 and 32 bit integers - ``ntohl,\nhtonl, ntohs, htons`` where \""n\"" means *network* and \""h\"" means *host*, \""s\"" means\n*short* and \""l\"" means *long*. Where network order is host order, these do\nnothing, but where the machine is byte-reversed, these swap the bytes around\nappropriately.\n\nIn these days of 64-bit machines, the ASCII representation of binary data is\nfrequently smaller than the binary representation. That's because a surprising\namount of the time, most integers have the value 0, or maybe 1.\nThe string ``\""0\""`` would be two bytes, while a full 64-bit integer would be 8.\nOf course, this doesn't fit well with fixed-length messages.\nDecisions, decisions.\n\n\nDisconnecting\n=============\n\nStrictly speaking, you're supposed to use ``shutdown`` on a socket before you\n``close`` it. The ``shutdown`` is an advisory to the socket at the other end.\nDepending on the argument you pass it, it can mean \""I'm not going to send\nanymore, but I'll still listen\"", or \""I'm not listening, good riddance!\"". Most\nsocket libraries, however, are so used to programmers neglecting to use this\npiece of etiquette that normally a ``close`` is the same as ``shutdown();\nclose()``. So in most situations, an explicit ``shutdown`` is not needed.\n\nOne way to use ``shutdown`` effectively is in an HTTP-like exchange. The client\nsends a request and then does a ``shutdown(1)``. This tells the server \""This\nclient is done sending, but can still receive.\"" The server can detect \""EOF\"" by\na receive of 0 bytes. It can assume it has the complete request. The server\nsends a reply. If the ``send`` completes successfully then, indeed, the client\nwas still receiving.\n\nPython takes the automatic shutdown a step further, and says that when a socket\nis garbage collected, it will automatically do a ``close`` if it's needed. But\nrelying on this is a very bad habit. If your socket just disappears without\ndoing a ``close``, the socket at the other end may hang indefinitely, thinking\nyou're just being slow. *Please* ``close`` your sockets when you're done.\n\n\nWhen Sockets Die\n----------------\n\nProbably the worst thing about using blocking sockets is what happens when the\nother side comes down hard (without doing a ``close``). Your socket is likely to\nhang. TCP is a reliable protocol, and it will wait a long, long time\nbefore giving up on a connection. If you're using threads, the entire thread is\nessentially dead. There's not much you can do about it. As long as you aren't\ndoing something dumb, like holding a lock while doing a blocking read, the\nthread isn't really consuming much in the way of resources. Do *not* try to kill\nthe thread - part of the reason that threads are more efficient than processes\nis that they avoid the overhead associated with the automatic recycling of\nresources. In other words, if you do manage to kill the thread, your whole\nprocess is likely to be screwed up.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/sockets.rst#codepoints:5708:11631"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/sockets.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-howto-sockets.rst-head1,dp-Python-howto-sockets.rst,Python 3.13.0 documentation: Creating a Socket,"[""Creating a Socket\n=================\n\nRoughly speaking, when you clicked on the link that brought you to this page,\nyour browser did something like the following::\n\n # create an INET, STREAMing socket\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # now connect to the web server on port 80 - the normal http port\n s.connect((\""www.python.org\"", 80))\n\nWhen the ``connect`` completes, the socket ``s`` can be used to send\nin a request for the text of the page. The same socket will read the\nreply, and then be destroyed. That's right, destroyed. Client sockets\nare normally only used for one exchange (or a small set of sequential\nexchanges).\n\nWhat happens in the web server is a bit more complex. First, the web server\ncreates a \""server socket\""::\n\n # create an INET, STREAMing socket\n serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # bind the socket to a public host, and a well-known port\n serversocket.bind((socket.gethostname(), 80))\n # become a server socket\n serversocket.listen(5)\n\nA couple things to notice: we used ``socket.gethostname()`` so that the socket\nwould be visible to the outside world. If we had used ``s.bind(('localhost',\n80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a \""server\"" socket,\nbut one that was only visible within the same machine. ``s.bind(('', 80))``\nspecifies that the socket is reachable by any address the machine happens to\nhave.\n\nA second thing to note: low number ports are usually reserved for \""well known\""\nservices (HTTP, SNMP etc). If you're playing around, use a nice high number (4\ndigits).\n\nFinally, the argument to ``listen`` tells the socket library that we want it to\nqueue up as many as 5 connect requests (the normal max) before refusing outside\nconnections. If the rest of the code is written properly, that should be plenty.\n\nNow that we have a \""server\"" socket, listening on port 80, we can enter the\nmainloop of the web server::\n\n while True:\n # accept connections from outside\n (clientsocket, address) = serversocket.accept()\n # now do something with the clientsocket\n # in this case, we'll pretend this is a threaded server\n ct = client_thread(clientsocket)\n ct.run()\n\nThere's actually 3 general ways in which this loop could work - dispatching a\nthread to handle ``clientsocket``, create a new process to handle\n``clientsocket``, or restructure this app to use non-blocking sockets, and\nmultiplex between our \""server\"" socket and any active ``clientsocket``\\ s using\n``select``. More about that later. The important thing to understand now is\nthis: this is *all* a \""server\"" socket does. It doesn't send any data. It doesn't\nreceive any data. It just produces \""client\"" sockets. Each ``clientsocket`` is\ncreated in response to some *other* \""client\"" socket doing a ``connect()`` to the\nhost and port we're bound to. As soon as we've created that ``clientsocket``, we\ngo back to listening for more connections. The two \""clients\"" are free to chat it\nup - they are using some dynamically allocated port which will be recycled when\nthe conversation ends.\n\n\nIPC\n---\n\nIf you need fast IPC between two processes on one machine, you should look into\npipes or shared memory. If you do decide to use AF_INET sockets, bind the\n\""server\"" socket to ``'localhost'``. On most platforms, this will take a\nshortcut around a couple of layers of network code and be quite a bit faster.\n\n.. seealso::\n The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level\n API.\n\n\n""]","[""Non-blocking Sockets\n====================\n\nIf you've understood the preceding, you already know most of what you need to\nknow about the mechanics of using sockets. You'll still use the same calls, in\nmuch the same ways. It's just that, if you do it right, your app will be almost\ninside-out.\n\nIn Python, you use ``socket.setblocking(False)`` to make it non-blocking. In C, it's\nmore complex, (for one thing, you'll need to choose between the BSD flavor\n``O_NONBLOCK`` and the almost indistinguishable POSIX flavor ``O_NDELAY``, which\nis completely different from ``TCP_NODELAY``), but it's the exact same idea. You\ndo this after creating the socket, but before using it. (Actually, if you're\nnuts, you can switch back and forth.)\n\nThe major mechanical difference is that ``send``, ``recv``, ``connect`` and\n``accept`` can return without having done anything. You have (of course) a\nnumber of choices. You can check return code and error codes and generally drive\nyourself crazy. If you don't believe me, try it sometime. Your app will grow\nlarge, buggy and suck CPU. So let's skip the brain-dead solutions and do it\nright.\n\nUse ``select``.\n\nIn C, coding ``select`` is fairly complex. In Python, it's a piece of cake, but\nit's close enough to the C version that if you understand ``select`` in Python,\nyou'll have little trouble with it in C::\n\n ready_to_read, ready_to_write, in_error = \\\n select.select(\n potential_readers,\n potential_writers,\n potential_errs,\n timeout)\n\nYou pass ``select`` three lists: the first contains all sockets that you might\nwant to try reading; the second all the sockets you might want to try writing\nto, and the last (normally left empty) those that you want to check for errors.\nYou should note that a socket can go into more than one list. The ``select``\ncall is blocking, but you can give it a timeout. This is generally a sensible\nthing to do - give it a nice long timeout (say a minute) unless you have good\nreason to do otherwise.\n\nIn return, you will get three lists. They contain the sockets that are actually\nreadable, writable and in error. Each of these lists is a subset (possibly\nempty) of the corresponding list you passed in.\n\nIf a socket is in the output readable list, you can be\nas-close-to-certain-as-we-ever-get-in-this-business that a ``recv`` on that\nsocket will return *something*. Same idea for the writable list. You'll be able\nto send *something*. Maybe not all you want to, but *something* is better than\nnothing. (Actually, any reasonably healthy socket will return as writable - it\njust means outbound network buffer space is available.)\n\nIf you have a \""server\"" socket, put it in the potential_readers list. If it comes\nout in the readable list, your ``accept`` will (almost certainly) work. If you\nhave created a new socket to ``connect`` to someone else, put it in the\npotential_writers list. If it shows up in the writable list, you have a decent\nchance that it has connected.\n\nActually, ``select`` can be handy even with blocking sockets. It's one way of\ndetermining whether you will block - the socket returns as readable when there's\nsomething in the buffers. However, this still doesn't help with the problem of\ndetermining whether the other end is done, or just busy with something else.\n\n**Portability alert**: On Unix, ``select`` works both with the sockets and\nfiles. Don't try this on Windows. On Windows, ``select`` works with sockets\nonly. Also note that in C, many of the more advanced socket options are done\ndifferently on Windows. In fact, on Windows I usually use threads (which work\nvery, very well) with my sockets.\n\n\n"", ""Using a Socket\n==============\n\nThe first thing to note, is that the web browser's \""client\"" socket and the web\nserver's \""client\"" socket are identical beasts. That is, this is a \""peer to peer\""\nconversation. Or to put it another way, *as the designer, you will have to\ndecide what the rules of etiquette are for a conversation*. Normally, the\n``connect``\\ ing socket starts the conversation, by sending in a request, or\nperhaps a signon. But that's a design decision - it's not a rule of sockets.\n\nNow there are two sets of verbs to use for communication. You can use ``send``\nand ``recv``, or you can transform your client socket into a file-like beast and\nuse ``read`` and ``write``. The latter is the way Java presents its sockets.\nI'm not going to talk about it here, except to warn you that you need to use\n``flush`` on sockets. These are buffered \""files\"", and a common mistake is to\n``write`` something, and then ``read`` for a reply. Without a ``flush`` in\nthere, you may wait forever for the reply, because the request may still be in\nyour output buffer.\n\nNow we come to the major stumbling block of sockets - ``send`` and ``recv`` operate\non the network buffers. They do not necessarily handle all the bytes you hand\nthem (or expect from them), because their major focus is handling the network\nbuffers. In general, they return when the associated network buffers have been\nfilled (``send``) or emptied (``recv``). They then tell you how many bytes they\nhandled. It is *your* responsibility to call them again until your message has\nbeen completely dealt with.\n\nWhen a ``recv`` returns 0 bytes, it means the other side has closed (or is in\nthe process of closing) the connection. You will not receive any more data on\nthis connection. Ever. You may be able to send data successfully; I'll talk\nmore about this later.\n\nA protocol like HTTP uses a socket for only one transfer. The client sends a\nrequest, then reads a reply. That's it. The socket is discarded. This means that\na client can detect the end of the reply by receiving 0 bytes.\n\nBut if you plan to reuse your socket for further transfers, you need to realize\nthat *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I repeat: if a socket\n``send`` or ``recv`` returns after handling 0 bytes, the connection has been\nbroken. If the connection has *not* been broken, you may wait on a ``recv``\nforever, because the socket will *not* tell you that there's nothing more to\nread (for now). Now if you think about that a bit, you'll come to realize a\nfundamental truth of sockets: *messages must either be fixed length* (yuck), *or\nbe delimited* (shrug), *or indicate how long they are* (much better), *or end by\nshutting down the connection*. The choice is entirely yours, (but some ways are\nrighter than others).\n\nAssuming you don't want to end the connection, the simplest solution is a fixed\nlength message::\n\n class MySocket:\n \""\""\""demonstration class only\n - coded for clarity, not efficiency\n \""\""\""\n\n def __init__(self, sock=None):\n if sock is None:\n self.sock = socket.socket(\n socket.AF_INET, socket.SOCK_STREAM)\n else:\n self.sock = sock\n\n def connect(self, host, port):\n self.sock.connect((host, port))\n\n def mysend(self, msg):\n totalsent = 0\n while totalsent < MSGLEN:\n sent = self.sock.send(msg[totalsent:])\n if sent == 0:\n raise RuntimeError(\""socket connection broken\"")\n totalsent = totalsent + sent\n\n def myreceive(self):\n chunks = []\n bytes_recd = 0\n while bytes_recd < MSGLEN:\n chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))\n if chunk == b'':\n raise RuntimeError(\""socket connection broken\"")\n chunks.append(chunk)\n bytes_recd = bytes_recd + len(chunk)\n return b''.join(chunks)\n\nThe sending code here is usable for almost any messaging scheme - in Python you\nsend strings, and you can use ``len()`` to determine its length (even if it has\nembedded ``\\0`` characters). It's mostly the receiving code that gets more\ncomplex. (And in C, it's not much worse, except you can't use ``strlen`` if the\nmessage has embedded ``\\0``\\ s.)\n\nThe easiest enhancement is to make the first character of the message an\nindicator of message type, and have the type determine the length. Now you have\ntwo ``recv``\\ s - the first to get (at least) that first character so you can\nlook up the length, and the second in a loop to get the rest. If you decide to\ngo the delimited route, you'll be receiving in some arbitrary chunk size, (4096\nor 8192 is frequently a good match for network buffer sizes), and scanning what\nyou've received for a delimiter.\n\nOne complication to be aware of: if your conversational protocol allows multiple\nmessages to be sent back to back (without some kind of reply), and you pass\n``recv`` an arbitrary chunk size, you may end up reading the start of a\nfollowing message. You'll need to put that aside and hold onto it, until it's\nneeded.\n\nPrefixing the message with its length (say, as 5 numeric characters) gets more\ncomplex, because (believe it or not), you may not get all 5 characters in one\n``recv``. In playing around, you'll get away with it; but in high network loads,\nyour code will very quickly break unless you use two ``recv`` loops - the first\nto determine the length, the second to get the data part of the message. Nasty.\nThis is also when you'll discover that ``send`` does not always manage to get\nrid of everything in one pass. And despite having read this, you will eventually\nget bit by it!\n\nIn the interests of space, building your character, (and preserving my\ncompetitive position), these enhancements are left as an exercise for the\nreader. Lets move on to cleaning up.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/sockets.rst#codepoints:2185:5708"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/sockets.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-howto-sockets.rst-head2,dp-Python-howto-sockets.rst,Python 3.13.0 documentation: Non-blocking Sockets,"[""Non-blocking Sockets\n====================\n\nIf you've understood the preceding, you already know most of what you need to\nknow about the mechanics of using sockets. You'll still use the same calls, in\nmuch the same ways. It's just that, if you do it right, your app will be almost\ninside-out.\n\nIn Python, you use ``socket.setblocking(False)`` to make it non-blocking. In C, it's\nmore complex, (for one thing, you'll need to choose between the BSD flavor\n``O_NONBLOCK`` and the almost indistinguishable POSIX flavor ``O_NDELAY``, which\nis completely different from ``TCP_NODELAY``), but it's the exact same idea. You\ndo this after creating the socket, but before using it. (Actually, if you're\nnuts, you can switch back and forth.)\n\nThe major mechanical difference is that ``send``, ``recv``, ``connect`` and\n``accept`` can return without having done anything. You have (of course) a\nnumber of choices. You can check return code and error codes and generally drive\nyourself crazy. If you don't believe me, try it sometime. Your app will grow\nlarge, buggy and suck CPU. So let's skip the brain-dead solutions and do it\nright.\n\nUse ``select``.\n\nIn C, coding ``select`` is fairly complex. In Python, it's a piece of cake, but\nit's close enough to the C version that if you understand ``select`` in Python,\nyou'll have little trouble with it in C::\n\n ready_to_read, ready_to_write, in_error = \\\n select.select(\n potential_readers,\n potential_writers,\n potential_errs,\n timeout)\n\nYou pass ``select`` three lists: the first contains all sockets that you might\nwant to try reading; the second all the sockets you might want to try writing\nto, and the last (normally left empty) those that you want to check for errors.\nYou should note that a socket can go into more than one list. The ``select``\ncall is blocking, but you can give it a timeout. This is generally a sensible\nthing to do - give it a nice long timeout (say a minute) unless you have good\nreason to do otherwise.\n\nIn return, you will get three lists. They contain the sockets that are actually\nreadable, writable and in error. Each of these lists is a subset (possibly\nempty) of the corresponding list you passed in.\n\nIf a socket is in the output readable list, you can be\nas-close-to-certain-as-we-ever-get-in-this-business that a ``recv`` on that\nsocket will return *something*. Same idea for the writable list. You'll be able\nto send *something*. Maybe not all you want to, but *something* is better than\nnothing. (Actually, any reasonably healthy socket will return as writable - it\njust means outbound network buffer space is available.)\n\nIf you have a \""server\"" socket, put it in the potential_readers list. If it comes\nout in the readable list, your ``accept`` will (almost certainly) work. If you\nhave created a new socket to ``connect`` to someone else, put it in the\npotential_writers list. If it shows up in the writable list, you have a decent\nchance that it has connected.\n\nActually, ``select`` can be handy even with blocking sockets. It's one way of\ndetermining whether you will block - the socket returns as readable when there's\nsomething in the buffers. However, this still doesn't help with the problem of\ndetermining whether the other end is done, or just busy with something else.\n\n**Portability alert**: On Unix, ``select`` works both with the sockets and\nfiles. Don't try this on Windows. On Windows, ``select`` works with sockets\nonly. Also note that in C, many of the more advanced socket options are done\ndifferently on Windows. In fact, on Windows I usually use threads (which work\nvery, very well) with my sockets.\n\n\n""]","[""Creating a Socket\n=================\n\nRoughly speaking, when you clicked on the link that brought you to this page,\nyour browser did something like the following::\n\n # create an INET, STREAMing socket\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # now connect to the web server on port 80 - the normal http port\n s.connect((\""www.python.org\"", 80))\n\nWhen the ``connect`` completes, the socket ``s`` can be used to send\nin a request for the text of the page. The same socket will read the\nreply, and then be destroyed. That's right, destroyed. Client sockets\nare normally only used for one exchange (or a small set of sequential\nexchanges).\n\nWhat happens in the web server is a bit more complex. First, the web server\ncreates a \""server socket\""::\n\n # create an INET, STREAMing socket\n serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n # bind the socket to a public host, and a well-known port\n serversocket.bind((socket.gethostname(), 80))\n # become a server socket\n serversocket.listen(5)\n\nA couple things to notice: we used ``socket.gethostname()`` so that the socket\nwould be visible to the outside world. If we had used ``s.bind(('localhost',\n80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a \""server\"" socket,\nbut one that was only visible within the same machine. ``s.bind(('', 80))``\nspecifies that the socket is reachable by any address the machine happens to\nhave.\n\nA second thing to note: low number ports are usually reserved for \""well known\""\nservices (HTTP, SNMP etc). If you're playing around, use a nice high number (4\ndigits).\n\nFinally, the argument to ``listen`` tells the socket library that we want it to\nqueue up as many as 5 connect requests (the normal max) before refusing outside\nconnections. If the rest of the code is written properly, that should be plenty.\n\nNow that we have a \""server\"" socket, listening on port 80, we can enter the\nmainloop of the web server::\n\n while True:\n # accept connections from outside\n (clientsocket, address) = serversocket.accept()\n # now do something with the clientsocket\n # in this case, we'll pretend this is a threaded server\n ct = client_thread(clientsocket)\n ct.run()\n\nThere's actually 3 general ways in which this loop could work - dispatching a\nthread to handle ``clientsocket``, create a new process to handle\n``clientsocket``, or restructure this app to use non-blocking sockets, and\nmultiplex between our \""server\"" socket and any active ``clientsocket``\\ s using\n``select``. More about that later. The important thing to understand now is\nthis: this is *all* a \""server\"" socket does. It doesn't send any data. It doesn't\nreceive any data. It just produces \""client\"" sockets. Each ``clientsocket`` is\ncreated in response to some *other* \""client\"" socket doing a ``connect()`` to the\nhost and port we're bound to. As soon as we've created that ``clientsocket``, we\ngo back to listening for more connections. The two \""clients\"" are free to chat it\nup - they are using some dynamically allocated port which will be recycled when\nthe conversation ends.\n\n\nIPC\n---\n\nIf you need fast IPC between two processes on one machine, you should look into\npipes or shared memory. If you do decide to use AF_INET sockets, bind the\n\""server\"" socket to ``'localhost'``. On most platforms, this will take a\nshortcut around a couple of layers of network code and be quite a bit faster.\n\n.. seealso::\n The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level\n API.\n\n\n"", "".. _socket-howto:\n\n****************************\n Socket Programming HOWTO\n****************************\n\n:Author: Gordon McMillan\n\n\n.. topic:: Abstract\n\n Sockets are used nearly everywhere, but are one of the most severely\n misunderstood technologies around. This is a 10,000 foot overview of sockets.\n It's not really a tutorial - you'll still have work to do in getting things\n operational. It doesn't cover the fine points (and there are a lot of them), but\n I hope it will give you enough background to begin using them decently.\n\n\nSockets\n=======\n\nI'm only going to talk about INET (i.e. IPv4) sockets, but they account for at least 99% of\nthe sockets in use. And I'll only talk about STREAM (i.e. TCP) sockets - unless you really\nknow what you're doing (in which case this HOWTO isn't for you!), you'll get\nbetter behavior and performance from a STREAM socket than anything else. I will\ntry to clear up the mystery of what a socket is, as well as some hints on how to\nwork with blocking and non-blocking sockets. But I'll start by talking about\nblocking sockets. You'll need to know how they work before dealing with\nnon-blocking sockets.\n\nPart of the trouble with understanding these things is that \""socket\"" can mean a\nnumber of subtly different things, depending on context. So first, let's make a\ndistinction between a \""client\"" socket - an endpoint of a conversation, and a\n\""server\"" socket, which is more like a switchboard operator. The client\napplication (your browser, for example) uses \""client\"" sockets exclusively; the\nweb server it's talking to uses both \""server\"" sockets and \""client\"" sockets.\n\n\nHistory\n-------\n\nOf the various forms of :abbr:`IPC (Inter Process Communication)`,\nsockets are by far the most popular. On any given platform, there are\nlikely to be other forms of IPC that are faster, but for\ncross-platform communication, sockets are about the only game in town.\n\nThey were invented in Berkeley as part of the BSD flavor of Unix. They spread\nlike wildfire with the internet. With good reason --- the combination of sockets\nwith INET makes talking to arbitrary machines around the world unbelievably easy\n(at least compared to other schemes).\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/howto/sockets.rst#codepoints:15096:18795"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:howto/sockets.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym0,dp-Python-library-aifc.rst,How is aifc.getcompname documented in Python 3.12.7?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym1,dp-Python-library-aifc.rst,Python 3.12.7: what does aifc.getsampwidth do?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym2,dp-Python-library-aifc.rst,Python 3.12.7: what does aifc.getnframes do?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym3,dp-Python-library-aifc.rst,What is the signature of aifc.getnchannels in Python 3.12.7?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym4,dp-Python-library-aifc.rst,How is aifc.open documented in Python 3.12.7?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-sym5,dp-Python-library-aifc.rst,How is aifc.tell documented in Python 3.12.7?,"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-aifc.rst-none0,dp-Python-library-aifc.rst,What is the signature of aifc.getcompname_strict in Python 3.12.7?,[],"["":mod:`aifc` --- Read and write AIFF and AIFC files\n==================================================\n\n.. module:: aifc\n :synopsis: Read and write audio files in AIFF or AIFC format.\n :deprecated:\n\n**Source code:** :source:`Lib/aifc.py`\n\n.. index::\n single: Audio Interchange File Format\n single: AIFF\n single: AIFF-C\n\n\n.. deprecated-removed:: 3.11 3.13\n The :mod:`aifc` module is deprecated\n (see :pep:`PEP 594 <594#aifc>` for details).\n\n--------------\n\nThis module provides support for reading and writing AIFF and AIFF-C files.\nAIFF is Audio Interchange File Format, a format for storing digital audio\nsamples in a file. AIFF-C is a newer version of the format that includes the\nability to compress the audio data.\n\nAudio files have a number of parameters that describe the audio data. The\nsampling rate or frame rate is the number of times per second the sound is\nsampled. The number of channels indicate if the audio is mono, stereo, or\nquadro. Each frame consists of one sample per channel. The sample size is the\nsize in bytes of each sample. Thus a frame consists of\n``nchannels * samplesize`` bytes, and a second's worth of audio consists of\n``nchannels * samplesize * framerate`` bytes.\n\nFor example, CD quality audio has a sample size of two bytes (16 bits), uses two\nchannels (stereo) and has a frame rate of 44,100 frames/second. This gives a\nframe size of 4 bytes (2\\*2), and a second's worth occupies 2\\*2\\*44100 bytes\n(176,400 bytes).\n\nModule :mod:`aifc` defines the following function:\n\n\n.. function:: open(file, mode=None)\n\n Open an AIFF or AIFF-C file and return an object instance with methods that are\n described below. The argument *file* is either a string naming a file or a\n :term:`file object`. *mode* must be ``'r'`` or ``'rb'`` when the file must be\n opened for reading, or ``'w'`` or ``'wb'`` when the file must be opened for writing.\n If omitted, ``file.mode`` is used if it exists, otherwise ``'rb'`` is used. When\n used for writing, the file object should be seekable, unless you know ahead of\n time how many samples you are going to write in total and use\n :meth:`writeframesraw` and :meth:`setnframes`.\n The :func:`.open` function may be used in a :keyword:`with` statement. When\n the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.\n\n .. versionchanged:: 3.4\n Support for the :keyword:`with` statement was added.\n\nObjects returned by :func:`.open` when a file is opened for reading have the\nfollowing methods:\n\n\n.. method:: aifc.getnchannels()\n\n Return the number of audio channels (1 for mono, 2 for stereo).\n\n\n.. method:: aifc.getsampwidth()\n\n Return the size in bytes of individual samples.\n\n\n.. method:: aifc.getframerate()\n\n Return the sampling rate (number of audio frames per second).\n\n\n.. method:: aifc.getnframes()\n\n Return the number of audio frames in the file.\n\n\n.. method:: aifc.getcomptype()\n\n Return a bytes array of length 4 describing the type of compression\n used in the audio file. For AIFF files, the returned value is\n ``b'NONE'``.\n\n\n.. method:: aifc.getcompname()\n\n Return a bytes array convertible to a human-readable description\n of the type of compression used in the audio file. For AIFF files,\n the returned value is ``b'not compressed'``.\n\n\n.. method:: aifc.getparams()\n\n Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth,\n framerate, nframes, comptype, compname)``, equivalent to output of the\n :meth:`get\\*` methods.\n\n\n.. method:: aifc.getmarkers()\n\n Return a list of markers in the audio file. A marker consists of a tuple of\n three elements. The first is the mark ID (an integer), the second is the mark\n position in frames from the beginning of the data (an integer), the third is the\n name of the mark (a string).\n\n\n.. method:: aifc.getmark(id)\n\n Return the tuple as described in :meth:`getmarkers` for the mark with the given\n *id*.\n\n\n.. method:: aifc.readframes(nframes)\n\n Read and return the next *nframes* frames from the audio file. The returned\n data is a string containing for each frame the uncompressed samples of all\n channels.\n\n\n.. method:: aifc.rewind()\n\n Rewind the read pointer. The next :meth:`readframes` will start from the\n beginning.\n\n\n.. method:: aifc.setpos(pos)\n\n Seek to the specified frame number.\n\n\n.. method:: aifc.tell()\n\n Return the current frame number.\n\n\n.. method:: aifc.close()\n\n Close the AIFF file. After calling this method, the object can no longer be\n used.\n\nObjects returned by :func:`.open` when a file is opened for writing have all the\nabove methods, except for :meth:`readframes` and :meth:`setpos`. In addition\nthe following methods exist. The :meth:`get\\*` methods can only be called after\nthe corresponding :meth:`set\\*` methods have been called. Before the first\n:meth:`writeframes` or :meth:`writeframesraw`, all parameters except for the\nnumber of frames must be filled in.\n\n\n.. method:: aifc.aiff()\n\n Create an AIFF file. The default is that an AIFF-C file is created, unless the\n name of the file ends in ``'.aiff'`` in which case the default is an AIFF file.\n\n\n.. method:: aifc.aifc()\n\n Create an AIFF-C file. The default is that an AIFF-C file is created, unless\n the name of the file ends in ``'.aiff'`` in which case the default is an AIFF\n file.\n\n\n.. method:: aifc.setnchannels(nchannels)\n\n Specify the number of channels in the audio file.\n\n\n.. method:: aifc.setsampwidth(width)\n\n Specify the size in bytes of audio samples.\n\n\n.. method:: aifc.setframerate(rate)\n\n Specify the sampling frequency in frames per second.\n\n\n.. method:: aifc.setnframes(nframes)\n\n Specify the number of frames that are to be written to the audio file. If this\n parameter is not set, or not set correctly, the file needs to support seeking.\n\n\n.. method:: aifc.setcomptype(type, name)\n\n .. index::\n single: u-LAW\n single: A-LAW\n single: G.722\n\n Specify the compression type. If not specified, the audio data will\n not be compressed. In AIFF files, compression is not possible.\n The name parameter should be a human-readable description of the\n compression type as a bytes array, the type parameter should be a\n bytes array of length 4. Currently the following compression types\n are supported: ``b'NONE'``, ``b'ULAW'``, ``b'ALAW'``, ``b'G722'``.\n\n\n.. method:: aifc.setparams(nchannels, sampwidth, framerate, comptype, compname)\n\n Set all the above parameters at once. The argument is a tuple consisting of the\n various parameters. This means that it is possible to use the result of a\n :meth:`getparams` call as argument to :meth:`setparams`.\n\n\n.. method:: aifc.setmark(id, pos, name)\n\n Add a mark with the given id (larger than 0), and the given name at the given\n position. This method can be called at any time before :meth:`close`.\n\n\n.. method:: aifc.tell()\n :noindex:\n\n Return the current write position in the output file. Useful in combination\n with :meth:`setmark`.\n\n\n.. method:: aifc.writeframes(data)\n\n Write data to the output file. This method can only be called after the audio\n file parameters have been set.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.writeframesraw(data)\n\n Like :meth:`writeframes`, except that the header of the audio file is not\n updated.\n\n .. versionchanged:: 3.4\n Any :term:`bytes-like object` is now accepted.\n\n\n.. method:: aifc.close()\n :noindex:\n\n Close the AIFF file. The header of the file is updated to reflect the actual\n size of the audio data. After calling this method, the object can no longer be\n used.\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/aifc.rst#codepoints:0:7670"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/aifc.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym0,dp-Python-library-email.policy.rst,Python 3.13.0: what does email.policy.EmailPolicy.refold_source do?,"["" email package policies, the *name* and *value* should be strings or\n string subclasses that do not change the content of the passed in\n arguments.\n\n There is no default implementation\n\n\n .. method:: header_fetch_parse(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` when that header is requested by the\n application program, and whatever the method returns is what is passed\n back to the application as the value of the header being retrieved.\n Note that there may be more than one header with the same name stored in\n the ``Message``; the method is passed the specific name and value of the\n header destined to be returned to the application.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the value returned by the method.\n\n There is no default implementation\n\n\n .. method:: fold(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` for a given header. The method should return a\n string that represents that header \""folded\"" correctly (according to the\n policy settings) by composing the *name* with the *value* and inserting\n :attr:`linesep` characters at the appropriate places. See :rfc:`5322`\n for a discussion of the rules for folding email headers.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the string returned by the method.\n\n\n .. method:: fold_binary(name, value)\n\n The same as :meth:`fold`, except that the returned value should be a\n bytes object rather than a string.\n\n *value* may contain surrogateescaped binary data. These could be\n converted back into binary data in the returned bytes object.\n\n\n\n.. class:: EmailPolicy(**kw)\n\n This concrete :class:`Policy` provides behavior that is intended to be fully\n compliant with the current email RFCs. These include (but are not limited\n to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs.\n\n This policy adds new header parsing and folding algorithms. Instead of\n simple strings, headers are ``str`` subclasses with attributes that depend\n on the type of the field. The parsing and folding algorithm fully implement\n :rfc:`2047` and :rfc:`5322`.\n\n The default value for the :attr:`~email.policy.Policy.message_factory`\n attribute is :class:`~email.message.EmailMessage`.\n\n In addition to the settable attributes listed above that apply to all\n policies, this policy adds the following additional attributes:\n\n .. versionadded:: 3.6 [1]_\n\n\n .. attribute:: utf8\n\n If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in\n headers by encoding them as \""encoded words\"". If ``True``, follow\n :rfc:`6532` and use ``utf-8`` encoding for headers. Messages\n formatted in this way may be passed to SMTP servers that support\n the ``SMTPUTF8`` extension (:rfc:`6531`).\n\n\n .. attribute:: refold_source\n\n If the value for a header in the ``Message`` object originated from a\n :mod:`~email.parser` (as opposed to being set by a program), this\n attribute indicates whether or not a generator should refold that value\n when transforming the message back into serialized form. The possible\n values are:\n\n ======== ===============================================================\n ``none`` all source values use original folding\n\n ``long`` source values that have any line that is longer than\n ``max_line_length`` will be refolded\n\n ``all`` all values are refolded.\n ======== ===============================================================\n\n The default is ``long``.\n\n\n .. attribute:: header_factory\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", ""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.13\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:14475:18361"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym1,dp-Python-library-email.policy.rst,What is the signature of email.policy.Policy.header_max_count in Python 3.13.0?,"["" A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n The default implementation checks the :attr:`raise_on_defect` flag. If\n it is ``True``, *defect* is raised as an exception. If it is ``False``\n (the default), *obj* and *defect* are passed to :meth:`register_defect`.\n\n\n .. method:: register_defect(obj, defect)\n\n Register a *defect* on *obj*. In the email package, *defect* will always\n be a subclass of :class:`~email.errors.Defect`.\n\n The default implementation calls the ``append`` method of the ``defects``\n attribute of *obj*. When the email package calls :attr:`handle_defect`,\n *obj* will normally have a ``defects`` attribute that has an ``append``\n method. Custom object types used with the email package (for example,\n custom ``Message`` objects) should also provide such an attribute,\n otherwise defects in parsed messages will raise unexpected errors.\n\n\n .. method:: header_max_count(name)\n\n Return the maximum allowed number of headers named *name*.\n\n Called when a header is added to an :class:`~email.message.EmailMessage`\n or :class:`~email.message.Message` object. If the returned value is not\n ``0`` or ``None``, and there are already a number of headers with the\n name *name* greater than or equal to the value returned, a\n :exc:`ValueError` is raised.\n\n Because the default behavior of ``Message.__setitem__`` is to append the\n value to the list of headers, it is easy to create duplicate headers\n without realizing it. This method allows certain headers to be limited\n in the number of instances of that header that may be added to a\n ``Message`` programmatically. (The limit is not observed by the parser,\n which will faithfully produce as many headers as exist in the message\n being parsed.)\n\n The default implementation returns ``None`` for all header names.\n\n\n .. method:: header_source_parse(sourcelines)\n\n The email package calls this method with a list of strings, each string\n ending with the line separation characters found in the source being\n parsed. The first line includes the field header name and separator.\n All whitespace in the source is preserved. The method should return the\n ``(name, value)`` tuple that is to be stored in the ``Message`` to\n represent the parsed header.\n\n If an implementation wishes to retain compatibility with the existing\n email package policies, *name* should be the case preserved name (all\n characters up to the '``:``' separator), while *value* should be the\n unfolded value (all line separator characters removed, but whitespace\n kept intact), stripped of leading whitespace.\n\n *sourcelines* may contain surrogateescaped binary data.\n\n There is no default implementation\n\n\n .. method:: header_store_parse(name, value)\n\n The email package calls this method with the name and value provided by\n the application program when the application program is modifying a\n ``Message`` programmatically (as opposed to a ``Message`` created by a\n parser). The method should return the ``(name, value)`` tuple that is to\n be stored in the ``Message`` to represent the header.\n\n If an implementation wishes to retain compatibility with the existing\n email package policies, the *name* and *value* should be strings or\n string subclasses that do not change the content of the passed in\n arguments.\n\n There is no default implementation\n\n\n .. method:: header_fetch_parse(name, value)\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", ""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.13\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:10914:14730"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym2,dp-Python-library-email.policy.rst,Python 3.13.0: what does email.policy.Policy.header_fetch_parse do?,"["" A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n The default implementation checks the :attr:`raise_on_defect` flag. If\n it is ``True``, *defect* is raised as an exception. If it is ``False``\n (the default), *obj* and *defect* are passed to :meth:`register_defect`.\n\n\n .. method:: register_defect(obj, defect)\n\n Register a *defect* on *obj*. In the email package, *defect* will always\n be a subclass of :class:`~email.errors.Defect`.\n\n The default implementation calls the ``append`` method of the ``defects``\n attribute of *obj*. When the email package calls :attr:`handle_defect`,\n *obj* will normally have a ``defects`` attribute that has an ``append``\n method. Custom object types used with the email package (for example,\n custom ``Message`` objects) should also provide such an attribute,\n otherwise defects in parsed messages will raise unexpected errors.\n\n\n .. method:: header_max_count(name)\n\n Return the maximum allowed number of headers named *name*.\n\n Called when a header is added to an :class:`~email.message.EmailMessage`\n or :class:`~email.message.Message` object. If the returned value is not\n ``0`` or ``None``, and there are already a number of headers with the\n name *name* greater than or equal to the value returned, a\n :exc:`ValueError` is raised.\n\n Because the default behavior of ``Message.__setitem__`` is to append the\n value to the list of headers, it is easy to create duplicate headers\n without realizing it. This method allows certain headers to be limited\n in the number of instances of that header that may be added to a\n ``Message`` programmatically. (The limit is not observed by the parser,\n which will faithfully produce as many headers as exist in the message\n being parsed.)\n\n The default implementation returns ``None`` for all header names.\n\n\n .. method:: header_source_parse(sourcelines)\n\n The email package calls this method with a list of strings, each string\n ending with the line separation characters found in the source being\n parsed. The first line includes the field header name and separator.\n All whitespace in the source is preserved. The method should return the\n ``(name, value)`` tuple that is to be stored in the ``Message`` to\n represent the parsed header.\n\n If an implementation wishes to retain compatibility with the existing\n email package policies, *name* should be the case preserved name (all\n characters up to the '``:``' separator), while *value* should be the\n unfolded value (all line separator characters removed, but whitespace\n kept intact), stripped of leading whitespace.\n\n *sourcelines* may contain surrogateescaped binary data.\n\n There is no default implementation\n\n\n .. method:: header_store_parse(name, value)\n\n The email package calls this method with the name and value provided by\n the application program when the application program is modifying a\n ``Message`` programmatically (as opposed to a ``Message`` created by a\n parser). The method should return the ``(name, value)`` tuple that is to\n be stored in the ``Message`` to represent the header.\n\n If an implementation wishes to retain compatibility with the existing\n email package policies, the *name* and *value* should be strings or\n string subclasses that do not change the content of the passed in\n arguments.\n\n There is no default implementation\n\n\n .. method:: header_fetch_parse(name, value)\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", ""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.13\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:10914:14730"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym3,dp-Python-library-email.policy.rst,What is the signature of email.policy.EmailPolicy.fold in Python 3.13.0?,"["" ``max_line_length`` will be refolded\n\n ``all`` all values are refolded.\n ======== ===============================================================\n\n The default is ``long``.\n\n\n .. attribute:: header_factory\n\n A callable that takes two arguments, ``name`` and ``value``, where\n ``name`` is a header field name and ``value`` is an unfolded header field\n value, and returns a string subclass that represents that header. A\n default ``header_factory`` (see :mod:`~email.headerregistry`) is provided\n that supports custom parsing for the various address and date :RFC:`5322`\n header field types, and the major MIME header field stypes. Support for\n additional custom parsing will be added in the future.\n\n\n .. attribute:: content_manager\n\n An object with at least two methods: get_content and set_content. When\n the :meth:`~email.message.EmailMessage.get_content` or\n :meth:`~email.message.EmailMessage.set_content` method of an\n :class:`~email.message.EmailMessage` object is called, it calls the\n corresponding method of this object, passing it the message object as its\n first argument, and any arguments or keywords that were passed to it as\n additional arguments. By default ``content_manager`` is set to\n :data:`~email.contentmanager.raw_data_manager`.\n\n .. versionadded:: 3.4\n\n\n The class provides the following concrete implementations of the abstract\n methods of :class:`Policy`:\n\n\n .. method:: header_max_count(name)\n\n Returns the value of the\n :attr:`~email.headerregistry.BaseHeader.max_count` attribute of the\n specialized class used to represent the header with the given name.\n\n\n .. method:: header_source_parse(sourcelines)\n\n\n The name is parsed as everything up to the '``:``' and returned\n unmodified. The value is determined by stripping leading whitespace off\n the remainder of the first line, joining all subsequent lines together,\n and stripping any trailing carriage return or linefeed characters.\n\n\n .. method:: header_store_parse(name, value)\n\n The name is returned unchanged. If the input value has a ``name``\n attribute and it matches *name* ignoring case, the value is returned\n unchanged. Otherwise the *name* and *value* are passed to\n ``header_factory``, and the resulting header object is returned as\n the value. In this case a ``ValueError`` is raised if the input value\n contains CR or LF characters.\n\n\n .. method:: header_fetch_parse(name, value)\n\n If the value has a ``name`` attribute, it is returned to unmodified.\n Otherwise the *name*, and the *value* with any CR or LF characters\n removed, are passed to the ``header_factory``, and the resulting\n header object is returned. Any surrogateescaped bytes get turned into\n the unicode unknown-character glyph.\n\n\n .. method:: fold(name, value)\n\n Header folding is controlled by the :attr:`refold_source` policy setting.\n A value is considered to be a 'source value' if and only if it does not\n have a ``name`` attribute (having a ``name`` attribute means it is a\n header object of some sort). If a source value needs to be refolded\n according to the policy, it is converted into a header object by\n passing the *name* and the *value* with any CR and LF characters removed\n to the ``header_factory``. Folding of a header object is done by\n calling its ``fold`` method with the current policy.\n\n Source values are split into lines using :meth:`~str.splitlines`. If\n the value is not to be refolded, the lines are rejoined using the\n ``linesep`` from the policy and returned. The exception is lines\n containing non-ascii binary data. In that case the value is refolded\n regardless of the ``refold_source`` setting, which causes the binary data\n to be CTE encoded using the ``unknown-8bit`` charset.\n\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", ""behavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\nAs an example, the following code could be used to read an email message from a\nfile on disk and pass it to the system ``sendmail`` program on a Unix system:\n\n.. testsetup::\n\n from unittest import mock\n mocker = mock.patch('subprocess.Popen')\n m = mocker.start()\n proc = mock.MagicMock()\n m.return_value = proc\n proc.stdin.close.return_value = None\n mymsg = open('mymsg.txt', 'w')\n mymsg.write('To: abc@xyz.com\\n\\n')\n mymsg.flush()\n\n.. doctest::\n\n >>> from email import message_from_binary_file\n >>> from email.generator import BytesGenerator\n >>> from email import policy\n >>> from subprocess import Popen, PIPE\n >>> with open('mymsg.txt', 'rb') as f:\n ... msg = message_from_binary_file(f, policy=policy.default)\n ...\n >>> p = Popen(['sendmail', msg['To'].addresses[0]], stdin=PIPE)\n >>> g = BytesGenerator(p.stdin, policy=msg.policy.clone(linesep='\\r\\n'))\n >>> g.flatten(msg)\n >>> p.stdin.close()\n >>> rc = p.wait()\n\n.. testcleanup::\n\n mymsg.close()\n mocker.stop()\n import os\n os.remove('mymsg.txt')\n\nHere we are telling :class:`~email.generator.BytesGenerator` to use the RFC\ncorrect line separator characters when creating the binary string to feed into\n``sendmail's`` ``stdin``, where the default policy would use ``\\n`` line\nseparators.\n\nSome email package methods accept a *policy* keyword argument, allowing the\npolicy to be overridden for that method. For example, the following code uses\nthe :meth:`~email.message.Message.as_bytes` method of the *msg* object from\nthe previous example and writes the message to a file using the native line\nseparators for the platform on which it is running::\n\n >>> import os\n >>> with open('converted.txt', 'wb') as f:\n ... f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))\n 17\n\nPolicy objects can also be combined using the addition operator, producing a\npolicy object whose settings are a combination of the non-default values of the\nsummed objects::\n\n >>> compat_SMTP = policy.compat32.clone(linesep='\\r\\n')\n >>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n >>> compat_strict_SMTP = compat_SMTP + compat_strict\n\nThis operation is not commutative; that is, the order in which the objects are\nadded matters. To illustrate::\n\n >>> policy100 = policy.compat32.clone(max_line_length=100)\n >>> policy80 = policy.compat32.clone(max_line_length=80)\n >>> apolicy = policy100 + policy80\n >>> apolicy.max_line_length\n 80\n >>> apolicy = policy80 + policy100\n >>> apolicy.max_line_length\n 100\n\n\n.. class:: Policy(**kw)\n\n This is the :term:`abstract base class` for all policy classes. It provides\n default implementations for a couple of trivial methods, as well as the\n implementation of the immutability property, the :meth:`clone` method, and\n the constructor semantics.\n\n The constructor of a policy class can be passed various keyword arguments.\n The arguments that may be specified are any non-method properties on this\n class, plus any additional non-method properties on the concrete class. A\n value specified in the constructor will override the default value for the\n corresponding attribute.\n\n This class defines the following properties, and thus values for the\n following may be passed in the constructor of any policy class:\n\n\n .. attribute:: max_line_length\n\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:18118:22101"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym4,dp-Python-library-email.policy.rst,What is the signature of email.policy.EmailPolicy.header_source_parse in Python 3.13.0?,"["" ``max_line_length`` will be refolded\n\n ``all`` all values are refolded.\n ======== ===============================================================\n\n The default is ``long``.\n\n\n .. attribute:: header_factory\n\n A callable that takes two arguments, ``name`` and ``value``, where\n ``name`` is a header field name and ``value`` is an unfolded header field\n value, and returns a string subclass that represents that header. A\n default ``header_factory`` (see :mod:`~email.headerregistry`) is provided\n that supports custom parsing for the various address and date :RFC:`5322`\n header field types, and the major MIME header field stypes. Support for\n additional custom parsing will be added in the future.\n\n\n .. attribute:: content_manager\n\n An object with at least two methods: get_content and set_content. When\n the :meth:`~email.message.EmailMessage.get_content` or\n :meth:`~email.message.EmailMessage.set_content` method of an\n :class:`~email.message.EmailMessage` object is called, it calls the\n corresponding method of this object, passing it the message object as its\n first argument, and any arguments or keywords that were passed to it as\n additional arguments. By default ``content_manager`` is set to\n :data:`~email.contentmanager.raw_data_manager`.\n\n .. versionadded:: 3.4\n\n\n The class provides the following concrete implementations of the abstract\n methods of :class:`Policy`:\n\n\n .. method:: header_max_count(name)\n\n Returns the value of the\n :attr:`~email.headerregistry.BaseHeader.max_count` attribute of the\n specialized class used to represent the header with the given name.\n\n\n .. method:: header_source_parse(sourcelines)\n\n\n The name is parsed as everything up to the '``:``' and returned\n unmodified. The value is determined by stripping leading whitespace off\n the remainder of the first line, joining all subsequent lines together,\n and stripping any trailing carriage return or linefeed characters.\n\n\n .. method:: header_store_parse(name, value)\n\n The name is returned unchanged. If the input value has a ``name``\n attribute and it matches *name* ignoring case, the value is returned\n unchanged. Otherwise the *name* and *value* are passed to\n ``header_factory``, and the resulting header object is returned as\n the value. In this case a ``ValueError`` is raised if the input value\n contains CR or LF characters.\n\n\n .. method:: header_fetch_parse(name, value)\n\n If the value has a ``name`` attribute, it is returned to unmodified.\n Otherwise the *name*, and the *value* with any CR or LF characters\n removed, are passed to the ``header_factory``, and the resulting\n header object is returned. Any surrogateescaped bytes get turned into\n the unicode unknown-character glyph.\n\n\n .. method:: fold(name, value)\n\n Header folding is controlled by the :attr:`refold_source` policy setting.\n A value is considered to be a 'source value' if and only if it does not\n have a ``name`` attribute (having a ``name`` attribute means it is a\n header object of some sort). If a source value needs to be refolded\n according to the policy, it is converted into a header object by\n passing the *name* and the *value* with any CR and LF characters removed\n to the ``header_factory``. Folding of a header object is done by\n calling its ``fold`` method with the current policy.\n\n Source values are split into lines using :meth:`~str.splitlines`. If\n the value is not to be refolded, the lines are rejoined using the\n ``linesep`` from the policy and returned. The exception is lines\n containing non-ascii binary data. In that case the value is refolded\n regardless of the ``refold_source`` setting, which causes the binary data\n to be CTE encoded using the ``unknown-8bit`` charset.\n\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", ""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.13\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:18118:22101"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-sym5,dp-Python-library-email.policy.rst,Python 3.13.0: what does email.policy.Policy.mangle_from_ do?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.13\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]","["":mod:`!email.policy`: Policy Objects\n------------------------------------\n\n.. module:: email.policy\n :synopsis: Controlling the parsing and generating of messages\n\n.. moduleauthor:: R. David Murray \n.. sectionauthor:: R. David Murray \n\n.. versionadded:: 3.3\n\n**Source code:** :source:`Lib/email/policy.py`\n\n--------------\n\nThe :mod:`email` package's prime focus is the handling of email messages as\ndescribed by the various email and MIME RFCs. However, the general format of\nemail messages (a block of header fields each consisting of a name followed by\na colon followed by a value, the whole block followed by a blank line and an\narbitrary 'body'), is a format that has found utility outside of the realm of\nemail. Some of these uses conform fairly closely to the main email RFCs, some\ndo not. Even when working with email, there are times when it is desirable to\nbreak strict compliance with the RFCs, such as generating emails that\ninteroperate with email servers that do not themselves follow the standards, or\nthat implement extensions you want to use in ways that violate the\nstandards.\n\nPolicy objects give the email package the flexibility to handle all these\ndisparate use cases.\n\nA :class:`Policy` object encapsulates a set of attributes and methods that\ncontrol the behavior of various components of the email package during use.\n:class:`Policy` instances can be passed to various classes and methods in the\nemail package to alter the default behavior. The settable values and their\ndefaults are described below.\n\nThere is a default policy used by all classes in the email package. For all of\nthe :mod:`~email.parser` classes and the related convenience functions, and for\nthe :class:`~email.message.Message` class, this is the :class:`Compat32`\npolicy, via its corresponding pre-defined instance :const:`compat32`. This\npolicy provides for complete backward compatibility (in some cases, including\nbug compatibility) with the pre-Python3.3 version of the email package.\n\nThis default value for the *policy* keyword to\n:class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via\nits pre-defined instance :data:`~default`.\n\nWhen a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`\nobject is created, it acquires a policy. If the message is created by a\n:mod:`~email.parser`, a policy passed to the parser will be the policy used by\nthe message it creates. If the message is created by the program, then the\npolicy can be specified when it is created. When a message is passed to a\n:mod:`~email.generator`, the generator uses the policy from the message by\ndefault, but you can also pass a specific policy to the generator that will\noverride the one stored on the message object.\n\nThe default value for the *policy* keyword for the :mod:`email.parser` classes\nand the parser convenience functions **will be changing** in a future version of\nPython. Therefore you should **always specify explicitly which policy you want\nto use** when calling any of the classes and functions described in the\n:mod:`~email.parser` module.\n\nThe first part of this documentation covers the features of :class:`Policy`, an\n:term:`abstract base class` that defines the features that are common to all\npolicy objects, including :const:`compat32`. This includes certain hook\nmethods that are called internally by the email package, which a custom policy\ncould override to obtain different behavior. The second part describes the\nconcrete classes :class:`EmailPolicy` and :class:`Compat32`, which implement\nthe hooks that provide the standard behavior and the backward compatible\nbehavior and features, respectively.\n\n:class:`Policy` instances are immutable, but they can be cloned, accepting the\nsame keyword arguments as the class constructor and returning a new\n:class:`Policy` instance that is a copy of the original but with the specified\nattributes values changed.\n\n"", "" email package policies, the *name* and *value* should be strings or\n string subclasses that do not change the content of the passed in\n arguments.\n\n There is no default implementation\n\n\n .. method:: header_fetch_parse(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` when that header is requested by the\n application program, and whatever the method returns is what is passed\n back to the application as the value of the header being retrieved.\n Note that there may be more than one header with the same name stored in\n the ``Message``; the method is passed the specific name and value of the\n header destined to be returned to the application.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the value returned by the method.\n\n There is no default implementation\n\n\n .. method:: fold(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` for a given header. The method should return a\n string that represents that header \""folded\"" correctly (according to the\n policy settings) by composing the *name* with the *value* and inserting\n :attr:`linesep` characters at the appropriate places. See :rfc:`5322`\n for a discussion of the rules for folding email headers.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the string returned by the method.\n\n\n .. method:: fold_binary(name, value)\n\n The same as :meth:`fold`, except that the returned value should be a\n bytes object rather than a string.\n\n *value* may contain surrogateescaped binary data. These could be\n converted back into binary data in the returned bytes object.\n\n\n\n.. class:: EmailPolicy(**kw)\n\n This concrete :class:`Policy` provides behavior that is intended to be fully\n compliant with the current email RFCs. These include (but are not limited\n to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs.\n\n This policy adds new header parsing and folding algorithms. Instead of\n simple strings, headers are ``str`` subclasses with attributes that depend\n on the type of the field. The parsing and folding algorithm fully implement\n :rfc:`2047` and :rfc:`5322`.\n\n The default value for the :attr:`~email.policy.Policy.message_factory`\n attribute is :class:`~email.message.EmailMessage`.\n\n In addition to the settable attributes listed above that apply to all\n policies, this policy adds the following additional attributes:\n\n .. versionadded:: 3.6 [1]_\n\n\n .. attribute:: utf8\n\n If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in\n headers by encoding them as \""encoded words\"". If ``True``, follow\n :rfc:`6532` and use ``utf-8`` encoding for headers. Messages\n formatted in this way may be passed to SMTP servers that support\n the ``SMTPUTF8`` extension (:rfc:`6531`).\n\n\n .. attribute:: refold_source\n\n If the value for a header in the ``Message`` object originated from a\n :mod:`~email.parser` (as opposed to being set by a program), this\n attribute indicates whether or not a generator should refold that value\n when transforming the message back into serialized form. The possible\n values are:\n\n ======== ===============================================================\n ``none`` all source values use original folding\n\n ``long`` source values that have any line that is longer than\n ``max_line_length`` will be refolded\n\n ``all`` all values are refolded.\n ======== ===============================================================\n\n The default is ``long``.\n\n\n .. attribute:: header_factory\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:7313:11180"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-email.policy.rst-none0,dp-Python-library-email.policy.rst,What is the signature of email.policy.EmailPolicy.refold_source_strict in Python 3.13.0?,[],"["" email package policies, the *name* and *value* should be strings or\n string subclasses that do not change the content of the passed in\n arguments.\n\n There is no default implementation\n\n\n .. method:: header_fetch_parse(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` when that header is requested by the\n application program, and whatever the method returns is what is passed\n back to the application as the value of the header being retrieved.\n Note that there may be more than one header with the same name stored in\n the ``Message``; the method is passed the specific name and value of the\n header destined to be returned to the application.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the value returned by the method.\n\n There is no default implementation\n\n\n .. method:: fold(name, value)\n\n The email package calls this method with the *name* and *value* currently\n stored in the ``Message`` for a given header. The method should return a\n string that represents that header \""folded\"" correctly (according to the\n policy settings) by composing the *name* with the *value* and inserting\n :attr:`linesep` characters at the appropriate places. See :rfc:`5322`\n for a discussion of the rules for folding email headers.\n\n *value* may contain surrogateescaped binary data. There should be no\n surrogateescaped binary data in the string returned by the method.\n\n\n .. method:: fold_binary(name, value)\n\n The same as :meth:`fold`, except that the returned value should be a\n bytes object rather than a string.\n\n *value* may contain surrogateescaped binary data. These could be\n converted back into binary data in the returned bytes object.\n\n\n\n.. class:: EmailPolicy(**kw)\n\n This concrete :class:`Policy` provides behavior that is intended to be fully\n compliant with the current email RFCs. These include (but are not limited\n to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs.\n\n This policy adds new header parsing and folding algorithms. Instead of\n simple strings, headers are ``str`` subclasses with attributes that depend\n on the type of the field. The parsing and folding algorithm fully implement\n :rfc:`2047` and :rfc:`5322`.\n\n The default value for the :attr:`~email.policy.Policy.message_factory`\n attribute is :class:`~email.message.EmailMessage`.\n\n In addition to the settable attributes listed above that apply to all\n policies, this policy adds the following additional attributes:\n\n .. versionadded:: 3.6 [1]_\n\n\n .. attribute:: utf8\n\n If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in\n headers by encoding them as \""encoded words\"". If ``True``, follow\n :rfc:`6532` and use ``utf-8`` encoding for headers. Messages\n formatted in this way may be passed to SMTP servers that support\n the ``SMTPUTF8`` extension (:rfc:`6531`).\n\n\n .. attribute:: refold_source\n\n If the value for a header in the ``Message`` object originated from a\n :mod:`~email.parser` (as opposed to being set by a program), this\n attribute indicates whether or not a generator should refold that value\n when transforming the message back into serialized form. The possible\n values are:\n\n ======== ===============================================================\n ``none`` all source values use original folding\n\n ``long`` source values that have any line that is longer than\n ``max_line_length`` will be refolded\n\n ``all`` all values are refolded.\n ======== ===============================================================\n\n The default is ``long``.\n\n\n .. attribute:: header_factory\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/email.policy.rst#codepoints:14475:18361"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym0,dp-Python-library-email.policy.rst,Python 3.12.7: what does email.policy.Policy.mangle_from_ do?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym1,dp-Python-library-email.policy.rst,Python 3.12.7: what does email.policy.Policy.clone do?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym2,dp-Python-library-email.policy.rst,How is email.policy.Policy.message_factory documented in Python 3.12.7?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym3,dp-Python-library-email.policy.rst,What is the signature of email.policy.Policy.raise_on_defect in Python 3.12.7?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym4,dp-Python-library-email.policy.rst,What is the signature of email.policy.Policy.handle_defect in Python 3.12.7?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-sym5,dp-Python-library-email.policy.rst,How is email.policy.Policy.verify_generated_headers documented in Python 3.12.7?,"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-email.policy.rst-none0,dp-Python-library-email.policy.rst,What is the signature of email.policy.Policy.mangle_from__strict in Python 3.12.7?,[],"[""\n The maximum length of any line in the serialized output, not counting the\n end of line character(s). Default is 78, per :rfc:`5322`. A value of\n ``0`` or :const:`None` indicates that no line wrapping should be\n done at all.\n\n\n .. attribute:: linesep\n\n The string to be used to terminate lines in serialized output. The\n default is ``\\n`` because that's the internal end-of-line discipline used\n by Python, though ``\\r\\n`` is required by the RFCs.\n\n\n .. attribute:: cte_type\n\n Controls the type of Content Transfer Encodings that may be or are\n required to be used. The possible values are:\n\n .. tabularcolumns:: |l|L|\n\n ======== ===============================================================\n ``7bit`` all data must be \""7 bit clean\"" (ASCII-only). This means that\n where necessary data will be encoded using either\n quoted-printable or base64 encoding.\n\n ``8bit`` data is not constrained to be 7 bit clean. Data in headers is\n still required to be ASCII-only and so will be encoded (see\n :meth:`fold_binary` and :attr:`~EmailPolicy.utf8` below for\n exceptions), but body parts may use the ``8bit`` CTE.\n ======== ===============================================================\n\n A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not\n ``Generator``, because strings cannot contain binary data. If a\n ``Generator`` is operating under a policy that specifies\n ``cte_type=8bit``, it will act as if ``cte_type`` is ``7bit``.\n\n\n .. attribute:: raise_on_defect\n\n If :const:`True`, any defects encountered will be raised as errors. If\n :const:`False` (the default), defects will be passed to the\n :meth:`register_defect` method.\n\n\n .. attribute:: mangle_from_\n\n If :const:`True`, lines starting with *\""From \""* in the body are\n escaped by putting a ``>`` in front of them. This parameter is used when\n the message is being serialized by a generator.\n Default: :const:`False`.\n\n .. versionadded:: 3.5\n\n\n .. attribute:: message_factory\n\n A factory function for constructing a new empty message object. Used\n by the parser when building messages. Defaults to ``None``, in\n which case :class:`~email.message.Message` is used.\n\n .. versionadded:: 3.6\n\n\n .. attribute:: verify_generated_headers\n\n If ``True`` (the default), the generator will raise\n :exc:`~email.errors.HeaderWriteError` instead of writing a header\n that is improperly folded or delimited, such that it would\n be parsed as multiple headers or joined with adjacent data.\n Such headers can be generated by custom header classes or bugs\n in the ``email`` module.\n\n As it's a security feature, this defaults to ``True`` even in the\n :class:`~email.policy.Compat32` policy.\n For backwards compatible, but unsafe, behavior, it must be set to\n ``False`` explicitly.\n\n .. versionadded:: 3.12.5\n\n\n The following :class:`Policy` method is intended to be called by code using\n the email library to create policy instances with custom settings:\n\n\n .. method:: clone(**kw)\n\n Return a new :class:`Policy` instance whose attributes have the same\n values as the current instance, except where those attributes are\n given new values by the keyword arguments.\n\n\n The remaining :class:`Policy` methods are called by the email package code,\n and are not intended to be called by an application using the email package.\n A custom policy must implement all of these methods.\n\n\n .. method:: handle_defect(obj, defect)\n\n Handle a *defect* found on *obj*. When the email package calls this\n method, *defect* will always be a subclass of\n :class:`~email.errors.Defect`.\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/email.policy.rst#codepoints:7313:11182"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/email.policy.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym0,dp-Python-library-errno.rst,What is the signature of errno.ENOANO in Python 3.13.0?,"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]","["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym1,dp-Python-library-errno.rst,Python 3.13.0: what does errno.ENODATA do?,"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]","["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym2,dp-Python-library-errno.rst,What is the signature of errno.EROFS in Python 3.13.0?,"["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]","[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:0:3977"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym3,dp-Python-library-errno.rst,What is the signature of errno.ENOTRECOVERABLE in Python 3.13.0?,"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]","["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym4,dp-Python-library-errno.rst,Python 3.13.0: what does errno.EREMCHG do?,"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]","["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-sym5,dp-Python-library-errno.rst,How is errno.EXFULL documented in Python 3.13.0?,"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]","["":mod:`!errno` --- Standard errno system symbols\n===============================================\n\n.. module:: errno\n :synopsis: Standard errno system symbols.\n\n----------------\n\nThis module makes available standard ``errno`` system symbols. The value of each\nsymbol is the corresponding integer value. The names and descriptions are\nborrowed from :file:`linux/include/errno.h`, which should be\nall-inclusive.\n\n\n.. data:: errorcode\n\n Dictionary providing a mapping from the errno value to the string name in the\n underlying system. For instance, ``errno.errorcode[errno.EPERM]`` maps to\n ``'EPERM'``.\n\nTo translate a numeric error code to an error message, use :func:`os.strerror`.\n\nOf the following list, symbols that are not used on the current platform are not\ndefined by the module. The specific list of defined symbols is available as\n``errno.errorcode.keys()``. Symbols available can include:\n\n\n.. data:: EPERM\n\n Operation not permitted. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: ENOENT\n\n No such file or directory. This error is mapped to the exception\n :exc:`FileNotFoundError`.\n\n\n.. data:: ESRCH\n\n No such process. This error is mapped to the exception\n :exc:`ProcessLookupError`.\n\n\n.. data:: EINTR\n\n Interrupted system call. This error is mapped to the exception\n :exc:`InterruptedError`.\n\n\n.. data:: EIO\n\n I/O error\n\n\n.. data:: ENXIO\n\n No such device or address\n\n\n.. data:: E2BIG\n\n Arg list too long\n\n\n.. data:: ENOEXEC\n\n Exec format error\n\n\n.. data:: EBADF\n\n Bad file number\n\n\n.. data:: ECHILD\n\n No child processes. This error is mapped to the exception\n :exc:`ChildProcessError`.\n\n\n.. data:: EAGAIN\n\n Try again. This error is mapped to the exception :exc:`BlockingIOError`.\n\n\n.. data:: ENOMEM\n\n Out of memory\n\n\n.. data:: EACCES\n\n Permission denied. This error is mapped to the exception\n :exc:`PermissionError`.\n\n\n.. data:: EFAULT\n\n Bad address\n\n\n.. data:: ENOTBLK\n\n Block device required\n\n\n.. data:: EBUSY\n\n Device or resource busy\n\n\n.. data:: EEXIST\n\n File exists. This error is mapped to the exception\n :exc:`FileExistsError`.\n\n\n.. data:: EXDEV\n\n Cross-device link\n\n\n.. data:: ENODEV\n\n No such device\n\n\n.. data:: ENOTDIR\n\n Not a directory. This error is mapped to the exception\n :exc:`NotADirectoryError`.\n\n\n.. data:: EISDIR\n\n Is a directory. This error is mapped to the exception\n :exc:`IsADirectoryError`.\n\n\n.. data:: EINVAL\n\n Invalid argument\n\n\n.. data:: ENFILE\n\n File table overflow\n\n\n.. data:: EMFILE\n\n Too many open files\n\n\n.. data:: ENOTTY\n\n Not a typewriter\n\n\n.. data:: ETXTBSY\n\n Text file busy\n\n\n.. data:: EFBIG\n\n File too large\n\n\n.. data:: ENOSPC\n\n No space left on device\n\n\n.. data:: ESPIPE\n\n Illegal seek\n\n\n.. data:: EROFS\n\n Read-only file system\n\n\n.. data:: EMLINK\n\n Too many links\n\n\n.. data:: EPIPE\n\n Broken pipe. This error is mapped to the exception\n :exc:`BrokenPipeError`.\n\n\n.. data:: EDOM\n\n Math argument out of domain of func\n\n\n.. data:: ERANGE\n\n Math result not representable\n\n\n.. data:: EDEADLK\n\n Resource deadlock would occur\n\n\n.. data:: ENAMETOOLONG\n\n File name too long\n\n\n.. data:: ENOLCK\n\n No record locks available\n\n\n.. data:: ENOSYS\n\n Function not implemented\n\n\n.. data:: ENOTEMPTY\n\n Directory not empty\n\n\n.. data:: ELOOP\n\n Too many symbolic links encountered\n\n\n.. data:: EWOULDBLOCK\n\n Operation would block. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ENOMSG\n\n No message of desired type\n\n\n.. data:: EIDRM\n\n Identifier removed\n\n\n.. data:: ECHRNG\n\n Channel number out of range\n\n\n.. data:: EL2NSYNC\n\n Level 2 not synchronized\n\n\n.. data:: EL3HLT\n\n Level 3 halted\n\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-errno.rst-none0,dp-Python-library-errno.rst,What is the signature of errno.ENOANO_strict in Python 3.13.0?,[],"[""\n\n.. data:: EL3RST\n\n Level 3 reset\n\n\n.. data:: ELNRNG\n\n Link number out of range\n\n\n.. data:: EUNATCH\n\n Protocol driver not attached\n\n\n.. data:: ENOCSI\n\n No CSI structure available\n\n\n.. data:: EL2HLT\n\n Level 2 halted\n\n\n.. data:: EBADE\n\n Invalid exchange\n\n\n.. data:: EBADR\n\n Invalid request descriptor\n\n\n.. data:: EXFULL\n\n Exchange full\n\n\n.. data:: ENOANO\n\n No anode\n\n\n.. data:: EBADRQC\n\n Invalid request code\n\n\n.. data:: EBADSLT\n\n Invalid slot\n\n\n.. data:: EDEADLOCK\n\n File locking deadlock error\n\n\n.. data:: EBFONT\n\n Bad font file format\n\n\n.. data:: ENOSTR\n\n Device not a stream\n\n\n.. data:: ENODATA\n\n No data available\n\n\n.. data:: ETIME\n\n Timer expired\n\n\n.. data:: ENOSR\n\n Out of streams resources\n\n\n.. data:: ENONET\n\n Machine is not on the network\n\n\n.. data:: ENOPKG\n\n Package not installed\n\n\n.. data:: EREMOTE\n\n Object is remote\n\n\n.. data:: ENOLINK\n\n Link has been severed\n\n\n.. data:: EADV\n\n Advertise error\n\n\n.. data:: ESRMNT\n\n Srmount error\n\n\n.. data:: ECOMM\n\n Communication error on send\n\n\n.. data:: EPROTO\n\n Protocol error\n\n\n.. data:: EMULTIHOP\n\n Multihop attempted\n\n\n.. data:: EDOTDOT\n\n RFS specific error\n\n\n.. data:: EBADMSG\n\n Not a data message\n\n\n.. data:: EOVERFLOW\n\n Value too large for defined data type\n\n\n.. data:: ENOTUNIQ\n\n Name not unique on network\n\n\n.. data:: EBADFD\n\n File descriptor in bad state\n\n\n.. data:: EREMCHG\n\n Remote address changed\n\n\n.. data:: ELIBACC\n\n Can not access a needed shared library\n\n\n.. data:: ELIBBAD\n\n Accessing a corrupted shared library\n\n\n.. data:: ELIBSCN\n\n .lib section in a.out corrupted\n\n\n.. data:: ELIBMAX\n\n Attempting to link in too many shared libraries\n\n\n.. data:: ELIBEXEC\n\n Cannot exec a shared library directly\n\n\n.. data:: EILSEQ\n\n Illegal byte sequence\n\n\n.. data:: ERESTART\n\n Interrupted system call should be restarted\n\n\n.. data:: ESTRPIPE\n\n Streams pipe error\n\n\n.. data:: EUSERS\n\n Too many users\n\n\n.. data:: ENOTSOCK\n\n Socket operation on non-socket\n\n\n.. data:: EDESTADDRREQ\n\n Destination address required\n\n\n.. data:: EMSGSIZE\n\n Message too long\n\n\n.. data:: EPROTOTYPE\n\n Protocol wrong type for socket\n\n\n.. data:: ENOPROTOOPT\n\n Protocol not available\n\n\n.. data:: EPROTONOSUPPORT\n\n Protocol not supported\n\n\n.. data:: ESOCKTNOSUPPORT\n\n Socket type not supported\n\n\n.. data:: EOPNOTSUPP\n\n Operation not supported on transport endpoint\n\n\n.. data:: ENOTSUP\n\n Operation not supported\n\n .. versionadded:: 3.2\n\n\n.. data:: EPFNOSUPPORT\n\n Protocol family not supported\n\n\n.. data:: EAFNOSUPPORT\n\n Address family not supported by protocol\n\n\n.. data:: EADDRINUSE\n\n Address already in use\n\n\n.. data:: EADDRNOTAVAIL\n\n Cannot assign requested address\n\n\n.. data:: ENETDOWN\n\n Network is down\n\n\n.. data:: ENETUNREACH\n\n Network is unreachable\n\n\n.. data:: ENETRESET\n\n Network dropped connection because of reset\n\n\n.. data:: ECONNABORTED\n\n Software caused connection abort. This error is mapped to the\n exception :exc:`ConnectionAbortedError`.\n\n\n.. data:: ECONNRESET\n\n Connection reset by peer. This error is mapped to the exception\n :exc:`ConnectionResetError`.\n\n\n.. data:: ENOBUFS\n\n No buffer space available\n\n\n.. data:: EISCONN\n\n Transport endpoint is already connected\n\n\n.. data:: ENOTCONN\n\n Transport endpoint is not connected\n\n\n.. data:: ESHUTDOWN\n\n Cannot send after transport endpoint shutdown. This error is mapped\n to the exception :exc:`BrokenPipeError`.\n\n\n.. data:: ETOOMANYREFS\n\n Too many references: cannot splice\n\n\n.. data:: ETIMEDOUT\n\n Connection timed out. This error is mapped to the exception\n :exc:`TimeoutError`.\n\n\n.. data:: ECONNREFUSED\n\n Connection refused. This error is mapped to the exception\n :exc:`ConnectionRefusedError`.\n\n\n.. data:: EHOSTDOWN\n\n Host is down\n\n\n.. data:: EHOSTUNREACH\n\n No route to host\n\n\n.. data:: EALREADY\n\n Operation already in progress. This error is mapped to the\n exception :exc:`BlockingIOError`.\n\n\n.. data:: EINPROGRESS\n\n Operation now in progress. This error is mapped to the exception\n :exc:`BlockingIOError`.\n\n\n.. data:: ESTALE\n\n Stale NFS file handle\n\n\n.. data:: EUCLEAN\n\n Structure needs cleaning\n\n\n.. data:: ENOTNAM\n\n Not a XENIX named type file\n\n\n.. data:: ENAVAIL\n\n No XENIX semaphores available\n\n\n.. data:: EISNAM\n\n Is a named type file\n\n\n.. data:: EREMOTEIO\n\n Remote I/O error\n\n\n.. data:: EDQUOT\n\n Quota exceeded\n\n.. data:: EQFULL\n\n Interface output queue is full\n\n .. versionadded:: 3.11\n\n.. data:: ENOTCAPABLE\n\n Capabilities insufficient. This error is mapped to the exception\n :exc:`PermissionError`.\n\n .. availability:: WASI, FreeBSD\n\n .. versionadded:: 3.11.1\n\n\n.. data:: ECANCELED\n\n Operation canceled\n\n .. versionadded:: 3.2\n\n\n.. data:: EOWNERDEAD\n\n Owner died\n\n .. versionadded:: 3.2\n\n\n.. data:: ENOTRECOVERABLE\n\n State not recoverable\n\n .. versionadded:: 3.2\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/errno.rst#codepoints:3693:8552"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/errno.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym0,dp-Python-library-msvcrt.rst,How is msvcrt.ungetwch documented in Python 3.13.0?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:3151:4565"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym1,dp-Python-library-msvcrt.rst,How is msvcrt.REPORT_ERRMODE documented in Python 3.13.0?,"[""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:4565:7539"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym2,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.get_osfhandle in Python 3.13.0?,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n"", ""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:0:3151"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym3,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.open_osfhandle in Python 3.13.0?,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n"", ""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:0:3151"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym4,dp-Python-library-msvcrt.rst,How is msvcrt.CrtSetReportMode documented in Python 3.13.0?,"[""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:4565:7539"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-sym5,dp-Python-library-msvcrt.rst,How is msvcrt.getche documented in Python 3.13.0?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:3151:4565"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-head0,dp-Python-library-msvcrt.rst,Python 3.13.0 documentation: Other Functions,"[""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:4565:7539"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-head1,dp-Python-library-msvcrt.rst,Python 3.13.0 documentation: Console I/O,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n"", ""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:3151:4565"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-head2,dp-Python-library-msvcrt.rst,Python 3.13.0 documentation: File Operations,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`,\n :const:`os.O_RDONLY`, :const:`os.O_TEXT` and :const:`os.O_NOINHERIT`.\n The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n The file descriptor is inheritable by default. Pass :const:`os.O_NOINHERIT`\n flag to make it non inheritable.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Other Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n\n.. function:: set_error_mode(mode)\n\n Changes the location where the C runtime writes an error message for an error\n that might end the program. *mode* must be one of the :const:`!OUT_\\*`\n constants listed below or :const:`REPORT_ERRMODE`. Returns the old setting\n or -1 if an error occurs. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_DEFAULT\n\n Error sink is determined by the app's type. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_STDERR\n\n Error sink is a standard error. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: OUT_TO_MSGBOX\n\n Error sink is a message box. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: REPORT_ERRMODE\n\n Report the current error mode value. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportMode(type, mode)\n\n Specifies the destination or destinations for a specific report type\n generated by :c:func:`!_CrtDbgReport` in the MS VC++ runtime. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *mode* must be one of the\n :const:`!CRTDBG_\\*` constants listed below. Only available in\n :ref:`debug build of Python `.\n\n\n.. function:: CrtSetReportFile(type, file)\n\n After you use :func:`CrtSetReportMode` to specify :const:`CRTDBG_MODE_FILE`,\n you can specify the file handle to receive the message text. *type* must be\n one of the :const:`!CRT_\\*` constants listed below. *file* should be the file\n handle your want specified. Only available in\n :ref:`debug build of Python `.\n\n\n.. data:: CRT_WARN\n\n Warnings, messages, and information that doesn't need immediate attention.\n\n\n.. data:: CRT_ERROR\n\n Errors, unrecoverable problems, and issues that require immediate attention.\n\n\n.. data:: CRT_ASSERT\n\n Assertion failures.\n\n\n.. data:: CRTDBG_MODE_DEBUG\n\n Writes the message to the debugger's output window.\n\n\n.. data:: CRTDBG_MODE_FILE\n\n Writes the message to a user-supplied file handle. :func:`CrtSetReportFile`\n should be called to define the specific file or stream to use as\n the destination.\n\n\n.. data:: CRTDBG_MODE_WNDW\n\n Creates a message box to display the message along with the ``Abort``,\n ``Retry``, and ``Ignore`` buttons.\n\n\n.. data:: CRTDBG_REPORT_MODE\n\n Returns current *mode* for the specified *type*.\n\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n"", ""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:0:3151"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-msvcrt.rst-none0,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.ungetwch_strict in Python 3.13.0?,[],"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Returns a nonzero value if a keypress is waiting to be read. Otherwise,\n return 0.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/msvcrt.rst#codepoints:3151:4565"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym0,dp-Python-library-msvcrt.rst,How is msvcrt.ungetwch documented in Python 3.12.7?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym1,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.get_osfhandle in Python 3.12.7?,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:0:3018"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym2,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.open_osfhandle in Python 3.12.7?,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:0:3018"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym3,dp-Python-library-msvcrt.rst,How is msvcrt.getche documented in Python 3.12.7?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym4,dp-Python-library-msvcrt.rst,How is msvcrt.putwch documented in Python 3.12.7?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-sym5,dp-Python-library-msvcrt.rst,How is msvcrt.putch documented in Python 3.12.7?,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-head0,dp-Python-library-msvcrt.rst,Python 3.12.7 documentation: Other Functions,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-head1,dp-Python-library-msvcrt.rst,Python 3.12.7 documentation: Console I/O,"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]","["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-head2,dp-Python-library-msvcrt.rst,Python 3.12.7 documentation: File Operations,"["":mod:`!msvcrt` --- Useful routines from the MS VC++ runtime\n===========================================================\n\n.. module:: msvcrt\n :platform: Windows\n :synopsis: Miscellaneous useful routines from the MS VC++ runtime.\n\n.. sectionauthor:: Fred L. Drake, Jr. \n\n--------------\n\nThese functions provide access to some useful capabilities on Windows platforms.\nSome higher-level modules use these functions to build the Windows\nimplementations of their services. For example, the :mod:`getpass` module uses\nthis in the implementation of the :func:`getpass` function.\n\nFurther documentation on these functions can be found in the Platform API\ndocumentation.\n\nThe module implements both the normal and wide char variants of the console I/O\napi. The normal API deals only with ASCII characters and is of limited use\nfor internationalized applications. The wide char API should be used where\never possible.\n\n.. versionchanged:: 3.3\n Operations in this module now raise :exc:`OSError` where :exc:`IOError`\n was raised.\n\n\n.. _msvcrt-files:\n\nFile Operations\n---------------\n\n\n.. function:: locking(fd, mode, nbytes)\n\n Lock part of a file based on file descriptor *fd* from the C runtime. Raises\n :exc:`OSError` on failure. The locked region of the file extends from the\n current file position for *nbytes* bytes, and may continue beyond the end of the\n file. *mode* must be one of the :const:`!LK_\\*` constants listed below. Multiple\n regions in a file may be locked at the same time, but may not overlap. Adjacent\n regions are not merged; they must be unlocked individually.\n\n .. audit-event:: msvcrt.locking fd,mode,nbytes msvcrt.locking\n\n\n.. data:: LK_LOCK\n LK_RLCK\n\n Locks the specified bytes. If the bytes cannot be locked, the program\n immediately tries again after 1 second. If, after 10 attempts, the bytes cannot\n be locked, :exc:`OSError` is raised.\n\n\n.. data:: LK_NBLCK\n LK_NBRLCK\n\n Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is\n raised.\n\n\n.. data:: LK_UNLCK\n\n Unlocks the specified bytes, which must have been previously locked.\n\n\n.. function:: setmode(fd, flags)\n\n Set the line-end translation mode for the file descriptor *fd*. To set it to\n text mode, *flags* should be :const:`os.O_TEXT`; for binary, it should be\n :const:`os.O_BINARY`.\n\n\n.. function:: open_osfhandle(handle, flags)\n\n Create a C runtime file descriptor from the file handle *handle*. The *flags*\n parameter should be a bitwise OR of :const:`os.O_APPEND`, :const:`os.O_RDONLY`,\n and :const:`os.O_TEXT`. The returned file descriptor may be used as a parameter\n to :func:`os.fdopen` to create a file object.\n\n .. audit-event:: msvcrt.open_osfhandle handle,flags msvcrt.open_osfhandle\n\n\n.. function:: get_osfhandle(fd)\n\n Return the file handle for the file descriptor *fd*. Raises :exc:`OSError` if\n *fd* is not recognized.\n\n .. audit-event:: msvcrt.get_osfhandle fd msvcrt.get_osfhandle\n\n\n.. _msvcrt-console:\n\n""]","[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:0:3018"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-msvcrt.rst-none0,dp-Python-library-msvcrt.rst,What is the signature of msvcrt.ungetwch_strict in Python 3.12.7?,[],"[""Console I/O\n-----------\n\n\n.. function:: kbhit()\n\n Return ``True`` if a keypress is waiting to be read.\n\n\n.. function:: getch()\n\n Read a keypress and return the resulting character as a byte string.\n Nothing is echoed to the console. This call will block if a keypress\n is not already available, but will not wait for :kbd:`Enter` to be\n pressed. If the pressed key was a special function key, this will\n return ``'\\000'`` or ``'\\xe0'``; the next call will return the keycode.\n The :kbd:`Control-C` keypress cannot be read with this function.\n\n\n.. function:: getwch()\n\n Wide char variant of :func:`getch`, returning a Unicode value.\n\n\n.. function:: getche()\n\n Similar to :func:`getch`, but the keypress will be echoed if it represents a\n printable character.\n\n\n.. function:: getwche()\n\n Wide char variant of :func:`getche`, returning a Unicode value.\n\n\n.. function:: putch(char)\n\n Print the byte string *char* to the console without buffering.\n\n\n.. function:: putwch(unicode_char)\n\n Wide char variant of :func:`putch`, accepting a Unicode value.\n\n\n.. function:: ungetch(char)\n\n Cause the byte string *char* to be \""pushed back\"" into the console buffer;\n it will be the next character read by :func:`getch` or :func:`getche`.\n\n\n.. function:: ungetwch(unicode_char)\n\n Wide char variant of :func:`ungetch`, accepting a Unicode value.\n\n\n.. _msvcrt-other:\n\nOther Functions\n---------------\n\n\n.. function:: heapmin()\n\n Force the :c:func:`malloc` heap to clean itself up and return unused blocks to\n the operating system. On failure, this raises :exc:`OSError`.\n\n.. data:: CRT_ASSEMBLY_VERSION\n\n The CRT Assembly version, from the :file:`crtassem.h` header file.\n\n\n.. data:: VC_ASSEMBLY_PUBLICKEYTOKEN\n\n The VC Assembly public key token, from the :file:`crtassem.h` header file.\n\n\n.. data:: LIBRARIES_ASSEMBLY_NAME_PREFIX\n\n The Libraries Assembly name prefix, from the :file:`crtassem.h` header file.\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/msvcrt.rst#codepoints:3018:4953"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/msvcrt.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym0,dp-Python-library-numbers.rst,Python 3.13.0: what does numbers.Complex do?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym1,dp-Python-library-numbers.rst,Python 3.13.0: what does numbers.Rational.denominator do?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym2,dp-Python-library-numbers.rst,How is numbers.Complex.real documented in Python 3.13.0?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]","[""Implementing the arithmetic operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe want to implement the arithmetic operations so that mixed-mode\noperations either call an implementation whose author knew about the\ntypes of both arguments, or convert both to the nearest built in type\nand do the operation there. For subtypes of :class:`Integral`, this\nmeans that :meth:`~object.__add__` and :meth:`~object.__radd__` should be\ndefined as::\n\n class MyIntegral(Integral):\n\n def __add__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(self, other)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(self, other)\n else:\n return NotImplemented\n\n def __radd__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(other, self)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(other, self)\n elif isinstance(other, Integral):\n return int(other) + int(self)\n elif isinstance(other, Real):\n return float(other) + float(self)\n elif isinstance(other, Complex):\n return complex(other) + complex(self)\n else:\n return NotImplemented\n\n\nThere are 5 different cases for a mixed-type operation on subclasses\nof :class:`Complex`. I'll refer to all of the above code that doesn't\nrefer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as\n\""boilerplate\"". ``a`` will be an instance of ``A``, which is a subtype\nof :class:`Complex` (``a : A <: Complex``), and ``b : B <:\nComplex``. I'll consider ``a + b``:\n\n1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is\n well.\n2. If ``A`` falls back to the boilerplate code, and it were to\n return a value from :meth:`~object.__add__`, we'd miss the possibility\n that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the\n boilerplate should return :data:`NotImplemented` from\n :meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at\n all.)\n3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts\n ``a``, all is well.\n4. If it falls back to the boilerplate, there are no more possible\n methods to try, so this is where the default implementation\n should live.\n5. If ``B <: A``, Python tries ``B.__radd__`` before\n ``A.__add__``. This is ok, because it was implemented with\n knowledge of ``A``, so it can handle those instances before\n delegating to :class:`Complex`.\n\nIf ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,\nthen the appropriate shared operation is the one involving the built\nin :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b\n== b+a``.\n\nBecause most of the operations on any given type will be very similar,\nit can be useful to define a helper function which generates the\nforward and reverse instances of any given operator. For example,\n:class:`fractions.Fraction` uses::\n\n def _operator_fallbacks(monomorphic_operator, fallback_operator):\n def forward(a, b):\n if isinstance(b, (int, Fraction)):\n return monomorphic_operator(a, b)\n elif isinstance(b, float):\n return fallback_operator(float(a), b)\n elif isinstance(b, complex):\n return fallback_operator(complex(a), b)\n else:\n return NotImplemented\n forward.__name__ = '__' + fallback_operator.__name__ + '__'\n forward.__doc__ = monomorphic_operator.__doc__\n\n def reverse(b, a):\n if isinstance(a, Rational):\n # Includes ints.\n return monomorphic_operator(a, b)\n elif isinstance(a, Real):\n return fallback_operator(float(a), float(b))\n elif isinstance(a, Complex):\n return fallback_operator(complex(a), complex(b))\n else:\n return NotImplemented\n reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n reverse.__doc__ = monomorphic_operator.__doc__\n\n return forward, reverse\n\n def _add(a, b):\n \""\""\""a + b\""\""\""\n return Fraction(a.numerator * b.denominator +\n b.numerator * a.denominator,\n a.denominator * b.denominator)\n\n __add__, __radd__ = _operator_fallbacks(_add, operator.add)\n\n # ...\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym3,dp-Python-library-numbers.rst,Python 3.13.0: what does numbers.Rational.numerator do?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym4,dp-Python-library-numbers.rst,How is numbers.Complex.imag documented in Python 3.13.0?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]","[""Implementing the arithmetic operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe want to implement the arithmetic operations so that mixed-mode\noperations either call an implementation whose author knew about the\ntypes of both arguments, or convert both to the nearest built in type\nand do the operation there. For subtypes of :class:`Integral`, this\nmeans that :meth:`~object.__add__` and :meth:`~object.__radd__` should be\ndefined as::\n\n class MyIntegral(Integral):\n\n def __add__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(self, other)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(self, other)\n else:\n return NotImplemented\n\n def __radd__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(other, self)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(other, self)\n elif isinstance(other, Integral):\n return int(other) + int(self)\n elif isinstance(other, Real):\n return float(other) + float(self)\n elif isinstance(other, Complex):\n return complex(other) + complex(self)\n else:\n return NotImplemented\n\n\nThere are 5 different cases for a mixed-type operation on subclasses\nof :class:`Complex`. I'll refer to all of the above code that doesn't\nrefer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as\n\""boilerplate\"". ``a`` will be an instance of ``A``, which is a subtype\nof :class:`Complex` (``a : A <: Complex``), and ``b : B <:\nComplex``. I'll consider ``a + b``:\n\n1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is\n well.\n2. If ``A`` falls back to the boilerplate code, and it were to\n return a value from :meth:`~object.__add__`, we'd miss the possibility\n that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the\n boilerplate should return :data:`NotImplemented` from\n :meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at\n all.)\n3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts\n ``a``, all is well.\n4. If it falls back to the boilerplate, there are no more possible\n methods to try, so this is where the default implementation\n should live.\n5. If ``B <: A``, Python tries ``B.__radd__`` before\n ``A.__add__``. This is ok, because it was implemented with\n knowledge of ``A``, so it can handle those instances before\n delegating to :class:`Complex`.\n\nIf ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,\nthen the appropriate shared operation is the one involving the built\nin :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b\n== b+a``.\n\nBecause most of the operations on any given type will be very similar,\nit can be useful to define a helper function which generates the\nforward and reverse instances of any given operator. For example,\n:class:`fractions.Fraction` uses::\n\n def _operator_fallbacks(monomorphic_operator, fallback_operator):\n def forward(a, b):\n if isinstance(b, (int, Fraction)):\n return monomorphic_operator(a, b)\n elif isinstance(b, float):\n return fallback_operator(float(a), b)\n elif isinstance(b, complex):\n return fallback_operator(complex(a), b)\n else:\n return NotImplemented\n forward.__name__ = '__' + fallback_operator.__name__ + '__'\n forward.__doc__ = monomorphic_operator.__doc__\n\n def reverse(b, a):\n if isinstance(a, Rational):\n # Includes ints.\n return monomorphic_operator(a, b)\n elif isinstance(a, Real):\n return fallback_operator(float(a), float(b))\n elif isinstance(a, Complex):\n return fallback_operator(complex(a), complex(b))\n else:\n return NotImplemented\n reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n reverse.__doc__ = monomorphic_operator.__doc__\n\n return forward, reverse\n\n def _add(a, b):\n \""\""\""a + b\""\""\""\n return Fraction(a.numerator * b.denominator +\n b.numerator * a.denominator,\n a.denominator * b.denominator)\n\n __add__, __radd__ = _operator_fallbacks(_add, operator.add)\n\n # ...\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-sym5,dp-Python-library-numbers.rst,What is the signature of numbers.Rational in Python 3.13.0?,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-head0,dp-Python-library-numbers.rst,Python 3.13.0 documentation: Implementing the arithmetic operations,"[""Implementing the arithmetic operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe want to implement the arithmetic operations so that mixed-mode\noperations either call an implementation whose author knew about the\ntypes of both arguments, or convert both to the nearest built in type\nand do the operation there. For subtypes of :class:`Integral`, this\nmeans that :meth:`~object.__add__` and :meth:`~object.__radd__` should be\ndefined as::\n\n class MyIntegral(Integral):\n\n def __add__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(self, other)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(self, other)\n else:\n return NotImplemented\n\n def __radd__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(other, self)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(other, self)\n elif isinstance(other, Integral):\n return int(other) + int(self)\n elif isinstance(other, Real):\n return float(other) + float(self)\n elif isinstance(other, Complex):\n return complex(other) + complex(self)\n else:\n return NotImplemented\n\n\nThere are 5 different cases for a mixed-type operation on subclasses\nof :class:`Complex`. I'll refer to all of the above code that doesn't\nrefer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as\n\""boilerplate\"". ``a`` will be an instance of ``A``, which is a subtype\nof :class:`Complex` (``a : A <: Complex``), and ``b : B <:\nComplex``. I'll consider ``a + b``:\n\n1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is\n well.\n2. If ``A`` falls back to the boilerplate code, and it were to\n return a value from :meth:`~object.__add__`, we'd miss the possibility\n that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the\n boilerplate should return :data:`NotImplemented` from\n :meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at\n all.)\n3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts\n ``a``, all is well.\n4. If it falls back to the boilerplate, there are no more possible\n methods to try, so this is where the default implementation\n should live.\n5. If ``B <: A``, Python tries ``B.__radd__`` before\n ``A.__add__``. This is ok, because it was implemented with\n knowledge of ``A``, so it can handle those instances before\n delegating to :class:`Complex`.\n\nIf ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,\nthen the appropriate shared operation is the one involving the built\nin :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b\n== b+a``.\n\nBecause most of the operations on any given type will be very similar,\nit can be useful to define a helper function which generates the\nforward and reverse instances of any given operator. For example,\n:class:`fractions.Fraction` uses::\n\n def _operator_fallbacks(monomorphic_operator, fallback_operator):\n def forward(a, b):\n if isinstance(b, (int, Fraction)):\n return monomorphic_operator(a, b)\n elif isinstance(b, float):\n return fallback_operator(float(a), b)\n elif isinstance(b, complex):\n return fallback_operator(complex(a), b)\n else:\n return NotImplemented\n forward.__name__ = '__' + fallback_operator.__name__ + '__'\n forward.__doc__ = monomorphic_operator.__doc__\n\n def reverse(b, a):\n if isinstance(a, Rational):\n # Includes ints.\n return monomorphic_operator(a, b)\n elif isinstance(a, Real):\n return fallback_operator(float(a), float(b))\n elif isinstance(a, Complex):\n return fallback_operator(complex(a), complex(b))\n else:\n return NotImplemented\n reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n reverse.__doc__ = monomorphic_operator.__doc__\n\n return forward, reverse\n\n def _add(a, b):\n \""\""\""a + b\""\""\""\n return Fraction(a.numerator * b.denominator +\n b.numerator * a.denominator,\n a.denominator * b.denominator)\n\n __add__, __radd__ = _operator_fallbacks(_add, operator.add)\n\n # ...\n""]","["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:3760:8263"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-head1,dp-Python-library-numbers.rst,Python 3.13.0 documentation: The numeric tower,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]","[""Implementing the arithmetic operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe want to implement the arithmetic operations so that mixed-mode\noperations either call an implementation whose author knew about the\ntypes of both arguments, or convert both to the nearest built in type\nand do the operation there. For subtypes of :class:`Integral`, this\nmeans that :meth:`~object.__add__` and :meth:`~object.__radd__` should be\ndefined as::\n\n class MyIntegral(Integral):\n\n def __add__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(self, other)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(self, other)\n else:\n return NotImplemented\n\n def __radd__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(other, self)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(other, self)\n elif isinstance(other, Integral):\n return int(other) + int(self)\n elif isinstance(other, Real):\n return float(other) + float(self)\n elif isinstance(other, Complex):\n return complex(other) + complex(self)\n else:\n return NotImplemented\n\n\nThere are 5 different cases for a mixed-type operation on subclasses\nof :class:`Complex`. I'll refer to all of the above code that doesn't\nrefer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as\n\""boilerplate\"". ``a`` will be an instance of ``A``, which is a subtype\nof :class:`Complex` (``a : A <: Complex``), and ``b : B <:\nComplex``. I'll consider ``a + b``:\n\n1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is\n well.\n2. If ``A`` falls back to the boilerplate code, and it were to\n return a value from :meth:`~object.__add__`, we'd miss the possibility\n that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the\n boilerplate should return :data:`NotImplemented` from\n :meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at\n all.)\n3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts\n ``a``, all is well.\n4. If it falls back to the boilerplate, there are no more possible\n methods to try, so this is where the default implementation\n should live.\n5. If ``B <: A``, Python tries ``B.__radd__`` before\n ``A.__add__``. This is ok, because it was implemented with\n knowledge of ``A``, so it can handle those instances before\n delegating to :class:`Complex`.\n\nIf ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,\nthen the appropriate shared operation is the one involving the built\nin :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b\n== b+a``.\n\nBecause most of the operations on any given type will be very similar,\nit can be useful to define a helper function which generates the\nforward and reverse instances of any given operator. For example,\n:class:`fractions.Fraction` uses::\n\n def _operator_fallbacks(monomorphic_operator, fallback_operator):\n def forward(a, b):\n if isinstance(b, (int, Fraction)):\n return monomorphic_operator(a, b)\n elif isinstance(b, float):\n return fallback_operator(float(a), b)\n elif isinstance(b, complex):\n return fallback_operator(complex(a), b)\n else:\n return NotImplemented\n forward.__name__ = '__' + fallback_operator.__name__ + '__'\n forward.__doc__ = monomorphic_operator.__doc__\n\n def reverse(b, a):\n if isinstance(a, Rational):\n # Includes ints.\n return monomorphic_operator(a, b)\n elif isinstance(a, Real):\n return fallback_operator(float(a), float(b))\n elif isinstance(a, Complex):\n return fallback_operator(complex(a), complex(b))\n else:\n return NotImplemented\n reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n reverse.__doc__ = monomorphic_operator.__doc__\n\n return forward, reverse\n\n def _add(a, b):\n \""\""\""a + b\""\""\""\n return Fraction(a.numerator * b.denominator +\n b.numerator * a.denominator,\n a.denominator * b.denominator)\n\n __add__, __radd__ = _operator_fallbacks(_add, operator.add)\n\n # ...\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-head2,dp-Python-library-numbers.rst,Python 3.13.0 documentation: Notes for type implementers,"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]","[""Implementing the arithmetic operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWe want to implement the arithmetic operations so that mixed-mode\noperations either call an implementation whose author knew about the\ntypes of both arguments, or convert both to the nearest built in type\nand do the operation there. For subtypes of :class:`Integral`, this\nmeans that :meth:`~object.__add__` and :meth:`~object.__radd__` should be\ndefined as::\n\n class MyIntegral(Integral):\n\n def __add__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(self, other)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(self, other)\n else:\n return NotImplemented\n\n def __radd__(self, other):\n if isinstance(other, MyIntegral):\n return do_my_adding_stuff(other, self)\n elif isinstance(other, OtherTypeIKnowAbout):\n return do_my_other_adding_stuff(other, self)\n elif isinstance(other, Integral):\n return int(other) + int(self)\n elif isinstance(other, Real):\n return float(other) + float(self)\n elif isinstance(other, Complex):\n return complex(other) + complex(self)\n else:\n return NotImplemented\n\n\nThere are 5 different cases for a mixed-type operation on subclasses\nof :class:`Complex`. I'll refer to all of the above code that doesn't\nrefer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as\n\""boilerplate\"". ``a`` will be an instance of ``A``, which is a subtype\nof :class:`Complex` (``a : A <: Complex``), and ``b : B <:\nComplex``. I'll consider ``a + b``:\n\n1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is\n well.\n2. If ``A`` falls back to the boilerplate code, and it were to\n return a value from :meth:`~object.__add__`, we'd miss the possibility\n that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the\n boilerplate should return :data:`NotImplemented` from\n :meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at\n all.)\n3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts\n ``a``, all is well.\n4. If it falls back to the boilerplate, there are no more possible\n methods to try, so this is where the default implementation\n should live.\n5. If ``B <: A``, Python tries ``B.__radd__`` before\n ``A.__add__``. This is ok, because it was implemented with\n knowledge of ``A``, so it can handle those instances before\n delegating to :class:`Complex`.\n\nIf ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,\nthen the appropriate shared operation is the one involving the built\nin :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b\n== b+a``.\n\nBecause most of the operations on any given type will be very similar,\nit can be useful to define a helper function which generates the\nforward and reverse instances of any given operator. For example,\n:class:`fractions.Fraction` uses::\n\n def _operator_fallbacks(monomorphic_operator, fallback_operator):\n def forward(a, b):\n if isinstance(b, (int, Fraction)):\n return monomorphic_operator(a, b)\n elif isinstance(b, float):\n return fallback_operator(float(a), b)\n elif isinstance(b, complex):\n return fallback_operator(complex(a), b)\n else:\n return NotImplemented\n forward.__name__ = '__' + fallback_operator.__name__ + '__'\n forward.__doc__ = monomorphic_operator.__doc__\n\n def reverse(b, a):\n if isinstance(a, Rational):\n # Includes ints.\n return monomorphic_operator(a, b)\n elif isinstance(a, Real):\n return fallback_operator(float(a), float(b))\n elif isinstance(a, Complex):\n return fallback_operator(complex(a), complex(b))\n else:\n return NotImplemented\n reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n reverse.__doc__ = monomorphic_operator.__doc__\n\n return forward, reverse\n\n def _add(a, b):\n \""\""\""a + b\""\""\""\n return Fraction(a.numerator * b.denominator +\n b.numerator * a.denominator,\n a.denominator * b.denominator)\n\n __add__, __radd__ = _operator_fallbacks(_add, operator.add)\n\n # ...\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-numbers.rst-none0,dp-Python-library-numbers.rst,What is the signature of numbers.Complex_strict in Python 3.13.0?,[],"["":mod:`!numbers` --- Numeric abstract base classes\n=================================================\n\n.. module:: numbers\n :synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).\n\n**Source code:** :source:`Lib/numbers.py`\n\n--------------\n\nThe :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric\n:term:`abstract base classes ` which progressively define\nmore operations. None of the types defined in this module are intended to be instantiated.\n\n\n.. class:: Number\n\n The root of the numeric hierarchy. If you just want to check if an argument\n *x* is a number, without caring what kind, use ``isinstance(x, Number)``.\n\n\nThe numeric tower\n-----------------\n\n.. class:: Complex\n\n Subclasses of this type describe complex numbers and include the operations\n that work on the built-in :class:`complex` type. These are: conversions to\n :class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,\n ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and\n ``!=``. All except ``-`` and ``!=`` are abstract.\n\n .. attribute:: real\n\n Abstract. Retrieves the real component of this number.\n\n .. attribute:: imag\n\n Abstract. Retrieves the imaginary component of this number.\n\n .. abstractmethod:: conjugate()\n\n Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate()\n == (1-3j)``.\n\n.. class:: Real\n\n To :class:`Complex`, :class:`!Real` adds the operations that work on real\n numbers.\n\n In short, those are: a conversion to :class:`float`, :func:`math.trunc`,\n :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,\n ``%``, ``<``, ``<=``, ``>``, and ``>=``.\n\n Real also provides defaults for :func:`complex`, :attr:`~Complex.real`,\n :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`.\n\n\n.. class:: Rational\n\n Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and\n :attr:`~Rational.denominator` properties. It also provides a default for\n :func:`float`.\n\n The :attr:`~Rational.numerator` and :attr:`~Rational.denominator` values\n should be instances of :class:`Integral` and should be in lowest terms with\n :attr:`~Rational.denominator` positive.\n\n .. attribute:: numerator\n\n Abstract.\n\n .. attribute:: denominator\n\n Abstract.\n\n\n.. class:: Integral\n\n Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides\n defaults for :func:`float`, :attr:`~Rational.numerator`, and\n :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with\n modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,\n ``~``.\n\n\nNotes for type implementers\n---------------------------\n\nImplementers should be careful to make equal numbers equal and hash\nthem to the same values. This may be subtle if there are two different\nextensions of the real numbers. For example, :class:`fractions.Fraction`\nimplements :func:`hash` as follows::\n\n def __hash__(self):\n if self.denominator == 1:\n # Get integers right.\n return hash(self.numerator)\n # Expensive check, but definitely correct.\n if self == float(self):\n return hash(float(self))\n else:\n # Use tuple's hash to avoid a high collision rate on\n # simple fractions.\n return hash((self.numerator, self.denominator))\n\n\nAdding More Numeric ABCs\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are, of course, more possible ABCs for numbers, and this would\nbe a poor hierarchy if it precluded the possibility of adding\nthose. You can add ``MyFoo`` between :class:`Complex` and\n:class:`Real` with::\n\n class MyFoo(Complex): ...\n MyFoo.register(Real)\n\n\n.. _implementing-the-arithmetic-operations:\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/numbers.rst#codepoints:0:3760"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/numbers.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym0,dp-Python-library-readline.rst,How is readline.set_pre_input_hook documented in Python 3.13.0?,"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]","[""Example\n-------\n\nThe following example demonstrates how to use the :mod:`readline` module's\nhistory reading and writing functions to automatically load and save a history\nfile named :file:`.python_history` from the user's home directory. The code\nbelow would normally be executed automatically during interactive sessions\nfrom the user's :envvar:`PYTHONSTARTUP` file. ::\n\n import atexit\n import os\n import readline\n\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n try:\n readline.read_history_file(histfile)\n # default history len is -1 (infinite), which may grow unruly\n readline.set_history_length(1000)\n except FileNotFoundError:\n pass\n\n atexit.register(readline.write_history_file, histfile)\n\nThis code is actually automatically run when Python is run in\n:ref:`interactive mode ` (see :ref:`rlcompleter-config`).\n\nThe following example achieves the same goal but supports concurrent interactive\nsessions, by only appending the new history. ::\n\n import atexit\n import os\n import readline\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n\n try:\n readline.read_history_file(histfile)\n h_len = readline.get_current_history_length()\n except FileNotFoundError:\n open(histfile, 'wb').close()\n h_len = 0\n\n def save(prev_h_len, histfile):\n new_h_len = readline.get_current_history_length()\n readline.set_history_length(1000)\n readline.append_history_file(new_h_len - prev_h_len, histfile)\n atexit.register(save, h_len, histfile)\n\nThe following example extends the :class:`code.InteractiveConsole` class to\nsupport history save/restore. ::\n\n import atexit\n import code\n import os\n import readline\n\n class HistoryConsole(code.InteractiveConsole):\n def __init__(self, locals=None, filename=\""\"",\n histfile=os.path.expanduser(\""~/.console-history\"")):\n code.InteractiveConsole.__init__(self, locals, filename)\n self.init_history(histfile)\n\n def init_history(self, histfile):\n readline.parse_and_bind(\""tab: complete\"")\n if hasattr(readline, \""read_history_file\""):\n try:\n readline.read_history_file(histfile)\n except FileNotFoundError:\n pass\n atexit.register(self.save_history, histfile)\n\n def save_history(self, histfile):\n readline.set_history_length(1000)\n readline.write_history_file(histfile)\n"", "":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym1,dp-Python-library-readline.rst,Python 3.13.0: what does readline.get_begidx do?,"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym2,dp-Python-library-readline.rst,Python 3.13.0: what does readline.add_history do?,"[""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:3271:6381"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym3,dp-Python-library-readline.rst,What is the signature of readline.get_completer in Python 3.13.0?,"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym4,dp-Python-library-readline.rst,How is readline.get_line_buffer documented in Python 3.13.0?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]","[""Example\n-------\n\nThe following example demonstrates how to use the :mod:`readline` module's\nhistory reading and writing functions to automatically load and save a history\nfile named :file:`.python_history` from the user's home directory. The code\nbelow would normally be executed automatically during interactive sessions\nfrom the user's :envvar:`PYTHONSTARTUP` file. ::\n\n import atexit\n import os\n import readline\n\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n try:\n readline.read_history_file(histfile)\n # default history len is -1 (infinite), which may grow unruly\n readline.set_history_length(1000)\n except FileNotFoundError:\n pass\n\n atexit.register(readline.write_history_file, histfile)\n\nThis code is actually automatically run when Python is run in\n:ref:`interactive mode ` (see :ref:`rlcompleter-config`).\n\nThe following example achieves the same goal but supports concurrent interactive\nsessions, by only appending the new history. ::\n\n import atexit\n import os\n import readline\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n\n try:\n readline.read_history_file(histfile)\n h_len = readline.get_current_history_length()\n except FileNotFoundError:\n open(histfile, 'wb').close()\n h_len = 0\n\n def save(prev_h_len, histfile):\n new_h_len = readline.get_current_history_length()\n readline.set_history_length(1000)\n readline.append_history_file(new_h_len - prev_h_len, histfile)\n atexit.register(save, h_len, histfile)\n\nThe following example extends the :class:`code.InteractiveConsole` class to\nsupport history save/restore. ::\n\n import atexit\n import code\n import os\n import readline\n\n class HistoryConsole(code.InteractiveConsole):\n def __init__(self, locals=None, filename=\""\"",\n histfile=os.path.expanduser(\""~/.console-history\"")):\n code.InteractiveConsole.__init__(self, locals, filename)\n self.init_history(histfile)\n\n def init_history(self, histfile):\n readline.parse_and_bind(\""tab: complete\"")\n if hasattr(readline, \""read_history_file\""):\n try:\n readline.read_history_file(histfile)\n except FileNotFoundError:\n pass\n atexit.register(self.save_history, histfile)\n\n def save_history(self, histfile):\n readline.set_history_length(1000)\n readline.write_history_file(histfile)\n"", ""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:0:3271"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-sym5,dp-Python-library-readline.rst,Python 3.13.0: what does readline.set_completion_display_matches_hook do?,"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-head0,dp-Python-library-readline.rst,Python 3.13.0 documentation: Line buffer,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]","[""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n"", ""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:0:3271"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-head1,dp-Python-library-readline.rst,Python 3.13.0 documentation: Completion,"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-head2,dp-Python-library-readline.rst,Python 3.13.0 documentation: History list,"[""History file\n------------\n\nThe following functions operate on a history file:\n\n\n.. function:: read_history_file([filename])\n\n Load a readline history file, and append it to the history list.\n The default filename is :file:`~/.history`. This calls\n :c:func:`read_history` in the underlying library.\n\n\n.. function:: write_history_file([filename])\n\n Save the history list to a readline history file, overwriting any\n existing file. The default filename is :file:`~/.history`. This calls\n :c:func:`write_history` in the underlying library.\n\n\n.. function:: append_history_file(nelements[, filename])\n\n Append the last *nelements* items of history to a file. The default filename is\n :file:`~/.history`. The file must already exist. This calls\n :c:func:`append_history` in the underlying library. This function\n only exists if Python was compiled for a version of the library\n that supports it.\n\n .. versionadded:: 3.5\n\n\n.. function:: get_history_length()\n set_history_length(length)\n\n Set or return the desired number of lines to save in the history file.\n The :func:`write_history_file` function uses this value to truncate\n the history file, by calling :c:func:`history_truncate_file` in\n the underlying library. Negative values imply\n unlimited history file size.\n\n\nHistory list\n------------\n\nThe following functions operate on a global history list:\n\n\n.. function:: clear_history()\n\n Clear the current history. This calls :c:func:`clear_history` in the\n underlying library. The Python function only exists if Python was\n compiled for a version of the library that supports it.\n\n\n.. function:: get_current_history_length()\n\n Return the number of items currently in the history. (This is different from\n :func:`get_history_length`, which returns the maximum number of lines that will\n be written to a history file.)\n\n\n.. function:: get_history_item(index)\n\n Return the current contents of history item at *index*. The item index\n is one-based. This calls :c:func:`history_get` in the underlying library.\n\n\n.. function:: remove_history_item(pos)\n\n Remove history item specified by its position from the history.\n The position is zero-based. This calls :c:func:`remove_history` in\n the underlying library.\n\n\n.. function:: replace_history_item(pos, line)\n\n Replace history item specified by its position with *line*.\n The position is zero-based. This calls :c:func:`replace_history_entry`\n in the underlying library.\n\n\n.. function:: add_history(line)\n\n Append *line* to the history buffer, as if it was the last line typed.\n This calls :c:func:`add_history` in the underlying library.\n\n\n.. function:: set_auto_history(enabled)\n\n Enable or disable automatic calls to :c:func:`add_history` when reading\n input via readline. The *enabled* argument should be a Boolean value\n that when true, enables auto history, and that when false, disables\n auto history.\n\n .. versionadded:: 3.6\n\n .. impl-detail::\n Auto history is enabled by default, and changes to this do not persist\n across multiple sessions.\n\n\n""]","["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. include:: ../includes/wasm-mobile-notavail.rst\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``editline`` (``libedit``) library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``editline`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can use :data:`backend` to determine which library is being used.\n\n If you use ``editline``/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n.. data:: backend\n\n The name of the underlying Readline library being used, either\n ``\""readline\""`` or ``\""editline\""``.\n\n .. versionadded:: 3.13\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n"", ""Example\n-------\n\nThe following example demonstrates how to use the :mod:`readline` module's\nhistory reading and writing functions to automatically load and save a history\nfile named :file:`.python_history` from the user's home directory. The code\nbelow would normally be executed automatically during interactive sessions\nfrom the user's :envvar:`PYTHONSTARTUP` file. ::\n\n import atexit\n import os\n import readline\n\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n try:\n readline.read_history_file(histfile)\n # default history len is -1 (infinite), which may grow unruly\n readline.set_history_length(1000)\n except FileNotFoundError:\n pass\n\n atexit.register(readline.write_history_file, histfile)\n\nThis code is actually automatically run when Python is run in\n:ref:`interactive mode ` (see :ref:`rlcompleter-config`).\n\nThe following example achieves the same goal but supports concurrent interactive\nsessions, by only appending the new history. ::\n\n import atexit\n import os\n import readline\n histfile = os.path.join(os.path.expanduser(\""~\""), \"".python_history\"")\n\n try:\n readline.read_history_file(histfile)\n h_len = readline.get_current_history_length()\n except FileNotFoundError:\n open(histfile, 'wb').close()\n h_len = 0\n\n def save(prev_h_len, histfile):\n new_h_len = readline.get_current_history_length()\n readline.set_history_length(1000)\n readline.append_history_file(new_h_len - prev_h_len, histfile)\n atexit.register(save, h_len, histfile)\n\nThe following example extends the :class:`code.InteractiveConsole` class to\nsupport history save/restore. ::\n\n import atexit\n import code\n import os\n import readline\n\n class HistoryConsole(code.InteractiveConsole):\n def __init__(self, locals=None, filename=\""\"",\n histfile=os.path.expanduser(\""~/.console-history\"")):\n code.InteractiveConsole.__init__(self, locals, filename)\n self.init_history(histfile)\n\n def init_history(self, histfile):\n readline.parse_and_bind(\""tab: complete\"")\n if hasattr(readline, \""read_history_file\""):\n try:\n readline.read_history_file(histfile)\n except FileNotFoundError:\n pass\n atexit.register(self.save_history, histfile)\n\n def save_history(self, histfile):\n readline.set_history_length(1000)\n readline.write_history_file(histfile)\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:3271:6381"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-readline.rst-none0,dp-Python-library-readline.rst,What is the signature of readline.set_pre_input_hook_strict in Python 3.13.0?,[],"[""Startup hooks\n-------------\n\n\n.. function:: set_startup_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_startup_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any function\n already installed is removed. The hook is called with no\n arguments just before readline prints the first prompt.\n\n\n.. function:: set_pre_input_hook([function])\n\n Set or remove the function invoked by the :c:data:`rl_pre_input_hook`\n callback of the underlying library. If *function* is specified, it will\n be used as the new hook function; if omitted or ``None``, any\n function already installed is removed. The hook is called\n with no arguments after the first prompt has been printed and just before\n readline starts reading input characters. This function only exists\n if Python was compiled for a version of the library that supports it.\n\n\n.. _readline-completion:\n\nCompletion\n----------\n\nThe following functions relate to implementing a custom word completion\nfunction. This is typically operated by the Tab key, and can suggest and\nautomatically complete a word being typed. By default, Readline is set up\nto be used by :mod:`rlcompleter` to complete Python identifiers for\nthe interactive interpreter. If the :mod:`readline` module is to be used\nwith a custom completer, a different set of word delimiters should be set.\n\n\n.. function:: set_completer([function])\n\n Set or remove the completer function. If *function* is specified, it will be\n used as the new completer function; if omitted or ``None``, any completer\n function already installed is removed. The completer function is called as\n ``function(text, state)``, for *state* in ``0``, ``1``, ``2``, ..., until it\n returns a non-string value. It should return the next possible completion\n starting with *text*.\n\n The installed completer function is invoked by the *entry_func* callback\n passed to :c:func:`rl_completion_matches` in the underlying library.\n The *text* string comes from the first parameter to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library.\n\n\n.. function:: get_completer()\n\n Get the completer function, or ``None`` if no completer function has been set.\n\n\n.. function:: get_completion_type()\n\n Get the type of completion being attempted. This returns the\n :c:data:`rl_completion_type` variable in the underlying library as\n an integer.\n\n\n.. function:: get_begidx()\n get_endidx()\n\n Get the beginning or ending index of the completion scope.\n These indexes are the *start* and *end* arguments passed to the\n :c:data:`rl_attempted_completion_function` callback of the\n underlying library. The values may be different in the same\n input editing scenario based on the underlying C readline implementation.\n Ex: libedit is known to behave differently than libreadline.\n\n\n.. function:: set_completer_delims(string)\n get_completer_delims()\n\n Set or get the word delimiters for completion. These determine the\n start of the word to be considered for completion (the completion scope).\n These functions access the :c:data:`rl_completer_word_break_characters`\n variable in the underlying library.\n\n\n.. function:: set_completion_display_matches_hook([function])\n\n Set or remove the completion display function. If *function* is\n specified, it will be used as the new completion display function;\n if omitted or ``None``, any completion display function already\n installed is removed. This sets or clears the\n :c:data:`rl_completion_display_matches_hook` callback in the\n underlying library. The completion display function is called as\n ``function(substitution, [matches], longest_match_length)`` once\n each time matches need to be displayed.\n\n\n.. _readline-example:\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/readline.rst#codepoints:6381:10278"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-sym0,dp-Python-library-readline.rst,How is readline.get_line_buffer documented in Python 3.12.7?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-sym1,dp-Python-library-readline.rst,Python 3.12.7: what does readline.redisplay do?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-sym2,dp-Python-library-readline.rst,Python 3.12.7: what does readline.parse_and_bind do?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-sym3,dp-Python-library-readline.rst,How is readline.insert_text documented in Python 3.12.7?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-sym4,dp-Python-library-readline.rst,How is readline.read_init_file documented in Python 3.12.7?,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-head0,dp-Python-library-readline.rst,Python 3.12.7 documentation: Line buffer,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-head1,dp-Python-library-readline.rst,Python 3.12.7 documentation: Init file,"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-readline.rst-none0,dp-Python-library-readline.rst,What is the signature of readline.get_line_buffer_strict in Python 3.12.7?,[],"["":mod:`!readline` --- GNU readline interface\n===========================================\n\n.. module:: readline\n :platform: Unix\n :synopsis: GNU readline support for Python.\n\n.. sectionauthor:: Skip Montanaro \n\n--------------\n\nThe :mod:`readline` module defines a number of functions to facilitate\ncompletion and reading/writing of history files from the Python interpreter.\nThis module can be used directly, or via the :mod:`rlcompleter` module, which\nsupports completion of Python identifiers at the interactive prompt. Settings\nmade using this module affect the behaviour of both the interpreter's\ninteractive prompt and the prompts offered by the built-in :func:`input`\nfunction.\n\nReadline keybindings may be configured via an initialization file, typically\n``.inputrc`` in your home directory. See `Readline Init File\n`_\nin the GNU Readline manual for information about the format and\nallowable constructs of that file, and the capabilities of the\nReadline library in general.\n\n.. note::\n\n The underlying Readline library API may be implemented by\n the ``libedit`` library instead of GNU readline.\n On macOS the :mod:`readline` module detects which library is being used\n at run time.\n\n The configuration file for ``libedit`` is different from that\n of GNU readline. If you programmatically load configuration strings\n you can check for the text \""libedit\"" in :const:`readline.__doc__`\n to differentiate between GNU readline and libedit.\n\n If you use *editline*/``libedit`` readline emulation on macOS, the\n initialization file located in your home directory is named\n ``.editrc``. For example, the following content in ``~/.editrc`` will\n turn ON *vi* keybindings and TAB completion::\n\n python:bind -v\n python:bind ^I rl_complete\n\n Also note that different libraries may use different history file formats.\n When switching the underlying library, existing history files may become\n unusable.\n\n\nInit file\n---------\n\nThe following functions relate to the init file and user configuration:\n\n\n.. function:: parse_and_bind(string)\n\n Execute the init line provided in the *string* argument. This calls\n :c:func:`rl_parse_and_bind` in the underlying library.\n\n\n.. function:: read_init_file([filename])\n\n Execute a readline initialization file. The default filename is the last filename\n used. This calls :c:func:`rl_read_init_file` in the underlying library.\n\n\nLine buffer\n-----------\n\nThe following functions operate on the line buffer:\n\n\n.. function:: get_line_buffer()\n\n Return the current contents of the line buffer (:c:data:`rl_line_buffer`\n in the underlying library).\n\n\n.. function:: insert_text(string)\n\n Insert text into the line buffer at the cursor position. This calls\n :c:func:`rl_insert_text` in the underlying library, but ignores\n the return value.\n\n\n.. function:: redisplay()\n\n Change what's displayed on the screen to reflect the current contents of the\n line buffer. This calls :c:func:`rl_redisplay` in the underlying library.\n\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/readline.rst#codepoints:0:3102"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/readline.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-library-tkinter.colorchooser.rst-sym0,dp-Python-library-tkinter.colorchooser.rst,What is the signature of tkinter.colorchooser.Chooser in Python 3.13.0?,"["":mod:`!tkinter.colorchooser` --- Color choosing dialog\n======================================================\n\n.. module:: tkinter.colorchooser\n :platform: Tk\n :synopsis: Color choosing dialog\n\n**Source code:** :source:`Lib/tkinter/colorchooser.py`\n\n--------------\n\nThe :mod:`tkinter.colorchooser` module provides the :class:`Chooser` class\nas an interface to the native color picker dialog. ``Chooser`` implements\na modal color choosing dialog window. The ``Chooser`` class inherits from\nthe :class:`~tkinter.commondialog.Dialog` class.\n\n.. class:: Chooser(master=None, **options)\n\n.. function:: askcolor(color=None, **options)\n\n Create a color choosing dialog. A call to this method will show the window,\n wait for the user to make a selection, and return the selected color (or\n ``None``) to the caller.\n\n\n.. seealso::\n\n Module :mod:`tkinter.commondialog`\n Tkinter standard dialog module\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tkinter.colorchooser.rst#codepoints:0:908"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tkinter.colorchooser.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tkinter.colorchooser.rst-sym1,dp-Python-library-tkinter.colorchooser.rst,How is tkinter.colorchooser.askcolor documented in Python 3.13.0?,"["":mod:`!tkinter.colorchooser` --- Color choosing dialog\n======================================================\n\n.. module:: tkinter.colorchooser\n :platform: Tk\n :synopsis: Color choosing dialog\n\n**Source code:** :source:`Lib/tkinter/colorchooser.py`\n\n--------------\n\nThe :mod:`tkinter.colorchooser` module provides the :class:`Chooser` class\nas an interface to the native color picker dialog. ``Chooser`` implements\na modal color choosing dialog window. The ``Chooser`` class inherits from\nthe :class:`~tkinter.commondialog.Dialog` class.\n\n.. class:: Chooser(master=None, **options)\n\n.. function:: askcolor(color=None, **options)\n\n Create a color choosing dialog. A call to this method will show the window,\n wait for the user to make a selection, and return the selected color (or\n ``None``) to the caller.\n\n\n.. seealso::\n\n Module :mod:`tkinter.commondialog`\n Tkinter standard dialog module\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tkinter.colorchooser.rst#codepoints:0:908"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tkinter.colorchooser.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tkinter.colorchooser.rst-none0,dp-Python-library-tkinter.colorchooser.rst,What is the signature of tkinter.colorchooser.Chooser_strict in Python 3.13.0?,[],"["":mod:`!tkinter.colorchooser` --- Color choosing dialog\n======================================================\n\n.. module:: tkinter.colorchooser\n :platform: Tk\n :synopsis: Color choosing dialog\n\n**Source code:** :source:`Lib/tkinter/colorchooser.py`\n\n--------------\n\nThe :mod:`tkinter.colorchooser` module provides the :class:`Chooser` class\nas an interface to the native color picker dialog. ``Chooser`` implements\na modal color choosing dialog window. The ``Chooser`` class inherits from\nthe :class:`~tkinter.commondialog.Dialog` class.\n\n.. class:: Chooser(master=None, **options)\n\n.. function:: askcolor(color=None, **options)\n\n Create a color choosing dialog. A call to this method will show the window,\n wait for the user to make a selection, and return the selected color (or\n ``None``) to the caller.\n\n\n.. seealso::\n\n Module :mod:`tkinter.commondialog`\n Tkinter standard dialog module\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tkinter.colorchooser.rst#codepoints:0:908"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tkinter.colorchooser.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym0,dp-Python-library-tokenize.rst,How is tokenize.generate_tokens documented in Python 3.13.0?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","["":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n"", ""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym1,dp-Python-library-tokenize.rst,How is tokenize.untokenize documented in Python 3.13.0?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","["":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n"", ""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym2,dp-Python-library-tokenize.rst,Python 3.13.0: what does tokenize.tokenize do?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym3,dp-Python-library-tokenize.rst,Python 3.13.0: what does tokenize.TokenError do?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","["":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n"", ""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym4,dp-Python-library-tokenize.rst,How is tokenize.detect_encoding documented in Python 3.13.0?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","["":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n"", ""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-sym5,dp-Python-library-tokenize.rst,What is the signature of tokenize.open in Python 3.13.0?,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","["":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n"", ""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-head0,dp-Python-library-tokenize.rst,Python 3.13.0 documentation: Command-Line Usage,"[""Command-Line Usage\n------------------\n\n.. versionadded:: 3.3\n\nThe :mod:`tokenize` module can be executed as a script from the command line.\nIt is as simple as:\n\n.. code-block:: sh\n\n python -m tokenize [-e] [filename.py]\n\nThe following options are accepted:\n\n.. program:: tokenize\n\n.. option:: -h, --help\n\n show this help message and exit\n\n.. option:: -e, --exact\n\n display token names using the exact type\n\nIf :file:`filename.py` is specified its contents are tokenized to stdout.\nOtherwise, tokenization is performed on stdin.\n\n""]","[""Examples\n------------------\n\nExample of a script rewriter that transforms float literals into Decimal\nobjects::\n\n from tokenize import tokenize, untokenize, NUMBER, STRING, NAME, OP\n from io import BytesIO\n\n def decistmt(s):\n \""\""\""Substitute Decimals for floats in a string of statements.\n\n >>> from decimal import Decimal\n >>> s = 'print(+21.3e-5*-.1234/81.7)'\n >>> decistmt(s)\n \""print (+Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7'))\""\n\n The format of the exponent is inherited from the platform C library.\n Known cases are \""e-007\"" (Windows) and \""e-07\"" (not Windows). Since\n we're only showing 12 digits, and the 13th isn't close to 5, the\n rest of the output should be platform-independent.\n\n >>> exec(s) #doctest: +ELLIPSIS\n -3.21716034272e-0...7\n\n Output from calculations with Decimal should be identical across all\n platforms.\n\n >>> exec(decistmt(s))\n -3.217160342717258261933904529E-7\n \""\""\""\n result = []\n g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string\n for toknum, tokval, _, _, _ in g:\n if toknum == NUMBER and '.' in tokval: # replace NUMBER tokens\n result.extend([\n (NAME, 'Decimal'),\n (OP, '('),\n (STRING, repr(tokval)),\n (OP, ')')\n ])\n else:\n result.append((toknum, tokval))\n return untokenize(result).decode('utf-8')\n\nExample of tokenizing from the command line. The script::\n\n def say_hello():\n print(\""Hello, World!\"")\n\n say_hello()\n\nwill be tokenized to the following output where the first column is the range\nof the line/column coordinates where the token is found, the second column is\nthe name of the token, and the final column is the value of the token (if any)\n\n.. code-block:: shell-session\n\n $ python -m tokenize hello.py\n 0,0-0,0: ENCODING 'utf-8'\n 1,0-1,3: NAME 'def'\n 1,4-1,13: NAME 'say_hello'\n 1,13-1,14: OP '('\n 1,14-1,15: OP ')'\n 1,15-1,16: OP ':'\n 1,16-1,17: NEWLINE '\\n'\n 2,0-2,4: INDENT ' '\n 2,4-2,9: NAME 'print'\n 2,9-2,10: OP '('\n 2,10-2,25: STRING '\""Hello, World!\""'\n 2,25-2,26: OP ')'\n 2,26-2,27: NEWLINE '\\n'\n 3,0-3,1: NL '\\n'\n 4,0-4,0: DEDENT ''\n 4,0-4,9: NAME 'say_hello'\n 4,9-4,10: OP '('\n 4,10-4,11: OP ')'\n 4,11-4,12: NEWLINE '\\n'\n 5,0-5,0: ENDMARKER ''\n\nThe exact token type names can be displayed using the :option:`-e` option:\n\n.. code-block:: shell-session\n\n $ python -m tokenize -e hello.py\n 0,0-0,0: ENCODING 'utf-8'\n 1,0-1,3: NAME 'def'\n 1,4-1,13: NAME 'say_hello'\n 1,13-1,14: LPAR '('\n 1,14-1,15: RPAR ')'\n 1,15-1,16: COLON ':'\n 1,16-1,17: NEWLINE '\\n'\n 2,0-2,4: INDENT ' '\n 2,4-2,9: NAME 'print'\n 2,9-2,10: LPAR '('\n 2,10-2,25: STRING '\""Hello, World!\""'\n 2,25-2,26: RPAR ')'\n 2,26-2,27: NEWLINE '\\n'\n 3,0-3,1: NL '\\n'\n 4,0-4,0: DEDENT ''\n 4,0-4,9: NAME 'say_hello'\n 4,9-4,10: LPAR '('\n 4,10-4,11: RPAR ')'\n 4,11-4,12: NEWLINE '\\n'\n 5,0-5,0: ENDMARKER ''\n\nExample of tokenizing a file programmatically, reading unicode\nstrings instead of bytes with :func:`generate_tokens`::\n\n import tokenize\n\n with tokenize.open('hello.py') as f:\n tokens = tokenize.generate_tokens(f.readline)\n for token in tokens:\n print(token)\n\nOr reading bytes directly with :func:`.tokenize`::\n\n import tokenize\n\n with open('hello.py', 'rb') as f:\n tokens = tokenize.tokenize(f.readline)\n for token in tokens:\n print(token)\n"", ""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:5640:6175"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-head1,dp-Python-library-tokenize.rst,Python 3.13.0 documentation: Tokenizing Input,"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]","[""Examples\n------------------\n\nExample of a script rewriter that transforms float literals into Decimal\nobjects::\n\n from tokenize import tokenize, untokenize, NUMBER, STRING, NAME, OP\n from io import BytesIO\n\n def decistmt(s):\n \""\""\""Substitute Decimals for floats in a string of statements.\n\n >>> from decimal import Decimal\n >>> s = 'print(+21.3e-5*-.1234/81.7)'\n >>> decistmt(s)\n \""print (+Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7'))\""\n\n The format of the exponent is inherited from the platform C library.\n Known cases are \""e-007\"" (Windows) and \""e-07\"" (not Windows). Since\n we're only showing 12 digits, and the 13th isn't close to 5, the\n rest of the output should be platform-independent.\n\n >>> exec(s) #doctest: +ELLIPSIS\n -3.21716034272e-0...7\n\n Output from calculations with Decimal should be identical across all\n platforms.\n\n >>> exec(decistmt(s))\n -3.217160342717258261933904529E-7\n \""\""\""\n result = []\n g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string\n for toknum, tokval, _, _, _ in g:\n if toknum == NUMBER and '.' in tokval: # replace NUMBER tokens\n result.extend([\n (NAME, 'Decimal'),\n (OP, '('),\n (STRING, repr(tokval)),\n (OP, ')')\n ])\n else:\n result.append((toknum, tokval))\n return untokenize(result).decode('utf-8')\n\nExample of tokenizing from the command line. The script::\n\n def say_hello():\n print(\""Hello, World!\"")\n\n say_hello()\n\nwill be tokenized to the following output where the first column is the range\nof the line/column coordinates where the token is found, the second column is\nthe name of the token, and the final column is the value of the token (if any)\n\n.. code-block:: shell-session\n\n $ python -m tokenize hello.py\n 0,0-0,0: ENCODING 'utf-8'\n 1,0-1,3: NAME 'def'\n 1,4-1,13: NAME 'say_hello'\n 1,13-1,14: OP '('\n 1,14-1,15: OP ')'\n 1,15-1,16: OP ':'\n 1,16-1,17: NEWLINE '\\n'\n 2,0-2,4: INDENT ' '\n 2,4-2,9: NAME 'print'\n 2,9-2,10: OP '('\n 2,10-2,25: STRING '\""Hello, World!\""'\n 2,25-2,26: OP ')'\n 2,26-2,27: NEWLINE '\\n'\n 3,0-3,1: NL '\\n'\n 4,0-4,0: DEDENT ''\n 4,0-4,9: NAME 'say_hello'\n 4,9-4,10: OP '('\n 4,10-4,11: OP ')'\n 4,11-4,12: NEWLINE '\\n'\n 5,0-5,0: ENDMARKER ''\n\nThe exact token type names can be displayed using the :option:`-e` option:\n\n.. code-block:: shell-session\n\n $ python -m tokenize -e hello.py\n 0,0-0,0: ENCODING 'utf-8'\n 1,0-1,3: NAME 'def'\n 1,4-1,13: NAME 'say_hello'\n 1,13-1,14: LPAR '('\n 1,14-1,15: RPAR ')'\n 1,15-1,16: COLON ':'\n 1,16-1,17: NEWLINE '\\n'\n 2,0-2,4: INDENT ' '\n 2,4-2,9: NAME 'print'\n 2,9-2,10: LPAR '('\n 2,10-2,25: STRING '\""Hello, World!\""'\n 2,25-2,26: RPAR ')'\n 2,26-2,27: NEWLINE '\\n'\n 3,0-3,1: NL '\\n'\n 4,0-4,0: DEDENT ''\n 4,0-4,9: NAME 'say_hello'\n 4,9-4,10: LPAR '('\n 4,10-4,11: RPAR ')'\n 4,11-4,12: NEWLINE '\\n'\n 5,0-5,0: ENDMARKER ''\n\nExample of tokenizing a file programmatically, reading unicode\nstrings instead of bytes with :func:`generate_tokens`::\n\n import tokenize\n\n with tokenize.open('hello.py') as f:\n tokens = tokenize.generate_tokens(f.readline)\n for token in tokens:\n print(token)\n\nOr reading bytes directly with :func:`.tokenize`::\n\n import tokenize\n\n with open('hello.py', 'rb') as f:\n tokens = tokenize.tokenize(f.readline)\n for token in tokens:\n print(token)\n"", "":mod:`!tokenize` --- Tokenizer for Python source\n================================================\n\n.. module:: tokenize\n :synopsis: Lexical scanner for Python source code.\n\n.. moduleauthor:: Ka Ping Yee\n.. sectionauthor:: Fred L. Drake, Jr. \n\n**Source code:** :source:`Lib/tokenize.py`\n\n--------------\n\nThe :mod:`tokenize` module provides a lexical scanner for Python source code,\nimplemented in Python. The scanner in this module returns comments as tokens\nas well, making it useful for implementing \""pretty-printers\"", including\ncolorizers for on-screen displays.\n\nTo simplify token stream handling, all :ref:`operator ` and\n:ref:`delimiter ` tokens and :data:`Ellipsis` are returned using\nthe generic :data:`~token.OP` token type. The exact\ntype can be determined by checking the ``exact_type`` property on the\n:term:`named tuple` returned from :func:`tokenize.tokenize`.\n\n\n.. warning::\n\n Note that the functions in this module are only designed to parse\n syntactically valid Python code (code that does not raise when parsed\n using :func:`ast.parse`). The behavior of the functions in this module is\n **undefined** when providing invalid Python code and it can change at any\n point.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-tokenize.rst-none0,dp-Python-library-tokenize.rst,What is the signature of tokenize.generate_tokens_strict in Python 3.13.0?,[],"[""Tokenizing Input\n----------------\n\nThe primary entry point is a :term:`generator`:\n\n.. function:: tokenize(readline)\n\n The :func:`.tokenize` generator requires one argument, *readline*, which\n must be a callable object which provides the same interface as the\n :meth:`io.IOBase.readline` method of file objects. Each call to the\n function should return one line of input as bytes.\n\n The generator produces 5-tuples with these members: the token type; the\n token string; a 2-tuple ``(srow, scol)`` of ints specifying the row and\n column where the token begins in the source; a 2-tuple ``(erow, ecol)`` of\n ints specifying the row and column where the token ends in the source; and\n the line on which the token was found. The line passed (the last tuple item)\n is the *physical* line. The 5 tuple is returned as a :term:`named tuple`\n with the field names:\n ``type string start end line``.\n\n The returned :term:`named tuple` has an additional property named\n ``exact_type`` that contains the exact operator type for\n :data:`~token.OP` tokens. For all other token types ``exact_type``\n equals the named tuple ``type`` field.\n\n .. versionchanged:: 3.1\n Added support for named tuples.\n\n .. versionchanged:: 3.3\n Added support for ``exact_type``.\n\n :func:`.tokenize` determines the source encoding of the file by looking for a\n UTF-8 BOM or encoding cookie, according to :pep:`263`.\n\n.. function:: generate_tokens(readline)\n\n Tokenize a source reading unicode strings instead of bytes.\n\n Like :func:`.tokenize`, the *readline* argument is a callable returning\n a single line of input. However, :func:`generate_tokens` expects *readline*\n to return a str object rather than bytes.\n\n The result is an iterator yielding named tuples, exactly like\n :func:`.tokenize`. It does not yield an :data:`~token.ENCODING` token.\n\nAll constants from the :mod:`token` module are also exported from\n:mod:`tokenize`.\n\nAnother function is provided to reverse the tokenization process. This is\nuseful for creating tools that tokenize a script, modify the token stream, and\nwrite back the modified script.\n\n\n.. function:: untokenize(iterable)\n\n Converts tokens back into Python source code. The *iterable* must return\n sequences with at least two elements, the token type and the token string.\n Any additional sequence elements are ignored.\n\n The reconstructed script is returned as a single string. The result is\n guaranteed to tokenize back to match the input so that the conversion is\n lossless and round-trips are assured. The guarantee applies only to the\n token type and token string as the spacing between tokens (column\n positions) may change.\n\n It returns bytes, encoded using the :data:`~token.ENCODING` token, which\n is the first token sequence output by :func:`.tokenize`. If there is no\n encoding token in the input, it returns a str instead.\n\n\n:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The\nfunction it uses to do this is available:\n\n.. function:: detect_encoding(readline)\n\n The :func:`detect_encoding` function is used to detect the encoding that\n should be used to decode a Python source file. It requires one argument,\n readline, in the same way as the :func:`.tokenize` generator.\n\n It will call readline a maximum of twice, and return the encoding used\n (as a string) and a list of any lines (not decoded from bytes) it has read\n in.\n\n It detects the encoding from the presence of a UTF-8 BOM or an encoding\n cookie as specified in :pep:`263`. If both a BOM and a cookie are present,\n but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,\n ``'utf-8-sig'`` will be returned as an encoding.\n\n If no encoding is specified, then the default of ``'utf-8'`` will be\n returned.\n\n Use :func:`.open` to open Python source files: it uses\n :func:`detect_encoding` to detect the file encoding.\n\n\n.. function:: open(filename)\n\n Open a file in read only mode using the encoding detected by\n :func:`detect_encoding`.\n\n .. versionadded:: 3.2\n\n.. exception:: TokenError\n\n Raised when either a docstring or expression that may be split over several\n lines is not completed anywhere in the file, for example::\n\n \""\""\""Beginning of\n docstring\n\n or::\n\n [1,\n 2,\n 3\n\n.. _tokenize-cli:\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/tokenize.rst#codepoints:1241:5640"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/tokenize.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym0,dp-Python-library-types.rst,What is the signature of types.CoroutineType in Python 3.13.0?,"[""Standard Interpreter Types\n--------------------------\n\nThis module provides names for many of the types that are required to\nimplement a Python interpreter. It deliberately avoids including some of\nthe types that arise only incidentally during processing such as the\n``listiterator`` type.\n\nTypical use of these names is for :func:`isinstance` or\n:func:`issubclass` checks.\n\n\nIf you instantiate any of these types, note that signatures may vary between Python versions.\n\nStandard names are defined for the following types:\n\n.. data:: NoneType\n\n The type of :data:`None`.\n\n .. versionadded:: 3.10\n\n\n.. data:: FunctionType\n LambdaType\n\n The type of user-defined functions and functions created by\n :keyword:`lambda` expressions.\n\n .. audit-event:: function.__new__ code types.FunctionType\n\n The audit event only occurs for direct instantiation of function objects,\n and is not raised for normal compilation.\n\n\n.. data:: GeneratorType\n\n The type of :term:`generator`-iterator objects, created by\n generator functions.\n\n\n.. data:: CoroutineType\n\n The type of :term:`coroutine` objects, created by\n :keyword:`async def` functions.\n\n .. versionadded:: 3.5\n\n\n.. data:: AsyncGeneratorType\n\n The type of :term:`asynchronous generator`-iterator objects, created by\n asynchronous generator functions.\n\n .. versionadded:: 3.6\n\n\n.. class:: CodeType(**kwargs)\n\n .. index:: pair: built-in function; compile\n\n The type of :ref:`code objects ` such as returned by :func:`compile`.\n\n .. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType\n\n Note that the audited arguments may not match the names or positions\n required by the initializer. The audit event only occurs for direct\n instantiation of code objects, and is not raised for normal compilation.\n\n.. data:: CellType\n\n The type for cell objects: such objects are used as containers for\n a function's free variables.\n\n .. versionadded:: 3.8\n\n\n.. data:: MethodType\n\n The type of methods of user-defined class instances.\n\n\n.. data:: BuiltinFunctionType\n BuiltinMethodType\n\n The type of built-in functions like :func:`len` or :func:`sys.exit`, and\n methods of built-in classes. (Here, the term \""built-in\"" means \""written in\n C\"".)\n\n\n.. data:: WrapperDescriptorType\n\n The type of methods of some built-in data types and base classes such as\n :meth:`object.__init__` or :meth:`object.__lt__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: MethodWrapperType\n\n The type of *bound* methods of some built-in data types and base classes.\n For example it is the type of :code:`object().__str__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: NotImplementedType\n\n The type of :data:`NotImplemented`.\n\n .. versionadded:: 3.10\n\n\n.. data:: MethodDescriptorType\n\n The type of methods of some built-in data types such as :meth:`str.join`.\n\n .. versionadded:: 3.7\n\n\n.. data:: ClassMethodDescriptorType\n\n The type of *unbound* class methods of some built-in data types such as\n ``dict.__dict__['fromkeys']``.\n\n .. versionadded:: 3.7\n\n\n.. class:: ModuleType(name, doc=None)\n\n The type of :term:`modules `. The constructor takes the name of the\n module to be created and optionally its :term:`docstring`.\n\n .. note::\n Use :func:`importlib.util.module_from_spec` to create a new module if you\n wish to set the various import-controlled attributes.\n\n .. attribute:: __doc__\n\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:4510:8290"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym1,dp-Python-library-types.rst,What is the signature of types.GenericAlias in Python 3.13.0?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n.. class:: CapsuleType\n\n The type of :ref:`capsule objects `.\n\n .. versionadded:: 3.13\n\n\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:7992:14505"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym2,dp-Python-library-types.rst,Python 3.13.0: what does types.MappingProxyType do?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n.. class:: CapsuleType\n\n The type of :ref:`capsule objects `.\n\n .. versionadded:: 3.13\n\n\n""]","[""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n"", "":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:7992:14505"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym3,dp-Python-library-types.rst,Python 3.13.0: what does types.MappingProxyType.keys do?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n.. class:: CapsuleType\n\n The type of :ref:`capsule objects `.\n\n .. versionadded:: 3.13\n\n\n""]","[""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n"", "":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:7992:14505"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym4,dp-Python-library-types.rst,How is types.ModuleType documented in Python 3.13.0?,"[""Standard Interpreter Types\n--------------------------\n\nThis module provides names for many of the types that are required to\nimplement a Python interpreter. It deliberately avoids including some of\nthe types that arise only incidentally during processing such as the\n``listiterator`` type.\n\nTypical use of these names is for :func:`isinstance` or\n:func:`issubclass` checks.\n\n\nIf you instantiate any of these types, note that signatures may vary between Python versions.\n\nStandard names are defined for the following types:\n\n.. data:: NoneType\n\n The type of :data:`None`.\n\n .. versionadded:: 3.10\n\n\n.. data:: FunctionType\n LambdaType\n\n The type of user-defined functions and functions created by\n :keyword:`lambda` expressions.\n\n .. audit-event:: function.__new__ code types.FunctionType\n\n The audit event only occurs for direct instantiation of function objects,\n and is not raised for normal compilation.\n\n\n.. data:: GeneratorType\n\n The type of :term:`generator`-iterator objects, created by\n generator functions.\n\n\n.. data:: CoroutineType\n\n The type of :term:`coroutine` objects, created by\n :keyword:`async def` functions.\n\n .. versionadded:: 3.5\n\n\n.. data:: AsyncGeneratorType\n\n The type of :term:`asynchronous generator`-iterator objects, created by\n asynchronous generator functions.\n\n .. versionadded:: 3.6\n\n\n.. class:: CodeType(**kwargs)\n\n .. index:: pair: built-in function; compile\n\n The type of :ref:`code objects ` such as returned by :func:`compile`.\n\n .. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType\n\n Note that the audited arguments may not match the names or positions\n required by the initializer. The audit event only occurs for direct\n instantiation of code objects, and is not raised for normal compilation.\n\n.. data:: CellType\n\n The type for cell objects: such objects are used as containers for\n a function's free variables.\n\n .. versionadded:: 3.8\n\n\n.. data:: MethodType\n\n The type of methods of user-defined class instances.\n\n\n.. data:: BuiltinFunctionType\n BuiltinMethodType\n\n The type of built-in functions like :func:`len` or :func:`sys.exit`, and\n methods of built-in classes. (Here, the term \""built-in\"" means \""written in\n C\"".)\n\n\n.. data:: WrapperDescriptorType\n\n The type of methods of some built-in data types and base classes such as\n :meth:`object.__init__` or :meth:`object.__lt__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: MethodWrapperType\n\n The type of *bound* methods of some built-in data types and base classes.\n For example it is the type of :code:`object().__str__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: NotImplementedType\n\n The type of :data:`NotImplemented`.\n\n .. versionadded:: 3.10\n\n\n.. data:: MethodDescriptorType\n\n The type of methods of some built-in data types such as :meth:`str.join`.\n\n .. versionadded:: 3.7\n\n\n.. data:: ClassMethodDescriptorType\n\n The type of *unbound* class methods of some built-in data types such as\n ``dict.__dict__['fromkeys']``.\n\n .. versionadded:: 3.7\n\n\n.. class:: ModuleType(name, doc=None)\n\n The type of :term:`modules `. The constructor takes the name of the\n module to be created and optionally its :term:`docstring`.\n\n .. note::\n Use :func:`importlib.util.module_from_spec` to create a new module if you\n wish to set the various import-controlled attributes.\n\n .. attribute:: __doc__\n\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:4510:8290"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-sym5,dp-Python-library-types.rst,What is the signature of types.DynamicClassAttribute in Python 3.13.0?,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with :class:`!SimpleNamespace` you can add and remove\n attributes.\n\n :py:class:`SimpleNamespace` objects may be initialized\n in the same way as :class:`dict`: either with keyword arguments,\n with a single positional argument, or with both.\n When initialized with keyword arguments,\n those are directly added to the underlying namespace.\n Alternatively, when initialized with a positional argument,\n the underlying namespace will be updated with key-value pairs\n from that argument (either a mapping object or\n an :term:`iterable` object producing key-value pairs).\n All such keys must be strings.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, mapping_or_iterable=(), /, **kwargs):\n self.__dict__.update(mapping_or_iterable)\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n :class:`!SimpleNamespace` objects are supported by :func:`copy.replace`.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n .. versionchanged:: 3.13\n Added support for an optional positional argument.\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""Dynamic Type Creation\n---------------------\n\n.. function:: new_class(name, bases=(), kwds=None, exec_body=None)\n\n Creates a class object dynamically using the appropriate metaclass.\n\n The first three arguments are the components that make up a class\n definition header: the class name, the base classes (in order), the\n keyword arguments (such as ``metaclass``).\n\n The *exec_body* argument is a callback that is used to populate the\n freshly created class namespace. It should accept the class namespace\n as its sole argument and update the namespace directly with the class\n contents. If no callback is provided, it has the same effect as passing\n in ``lambda ns: None``.\n\n .. versionadded:: 3.3\n\n.. function:: prepare_class(name, bases=(), kwds=None)\n\n Calculates the appropriate metaclass and creates the class namespace.\n\n The arguments are the components that make up a class definition header:\n the class name, the base classes (in order) and the keyword arguments\n (such as ``metaclass``).\n\n The return value is a 3-tuple: ``metaclass, namespace, kwds``\n\n *metaclass* is the appropriate metaclass, *namespace* is the\n prepared class namespace and *kwds* is an updated copy of the passed\n in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*\n argument is passed in, this will be an empty dict.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.6\n\n The default value for the ``namespace`` element of the returned\n tuple has changed. Now an insertion-order-preserving mapping is\n used when the metaclass does not have a ``__prepare__`` method.\n\n.. seealso::\n\n :ref:`metaclasses`\n Full details of the class creation process supported by these functions\n\n :pep:`3115` - Metaclasses in Python 3000\n Introduced the ``__prepare__`` namespace hook\n\n.. function:: resolve_bases(bases)\n\n Resolve MRO entries dynamically as specified by :pep:`560`.\n\n This function looks for items in *bases* that are not instances of\n :class:`type`, and returns a tuple where each such object that has\n an :meth:`~object.__mro_entries__` method is replaced with an unpacked result of\n calling this method. If a *bases* item is an instance of :class:`type`,\n or it doesn't have an :meth:`!__mro_entries__` method, then it is included in\n the return tuple unchanged.\n\n .. versionadded:: 3.7\n\n.. function:: get_original_bases(cls, /)\n\n Return the tuple of objects originally given as the bases of *cls* before\n the :meth:`~object.__mro_entries__` method has been called on any bases\n (following the mechanisms laid out in :pep:`560`). This is useful for\n introspecting :ref:`Generics `.\n\n For classes that have an ``__orig_bases__`` attribute, this\n function returns the value of ``cls.__orig_bases__``.\n For classes without the ``__orig_bases__`` attribute,\n :attr:`cls.__bases__ ` is returned.\n\n Examples::\n\n from typing import TypeVar, Generic, NamedTuple, TypedDict\n\n T = TypeVar(\""T\"")\n class Foo(Generic[T]): ...\n class Bar(Foo[int], float): ...\n class Baz(list[str]): ...\n Eggs = NamedTuple(\""Eggs\"", [(\""a\"", int), (\""b\"", str)])\n Spam = TypedDict(\""Spam\"", {\""a\"": int, \""b\"": str})\n\n assert Bar.__bases__ == (Foo, float)\n assert get_original_bases(Bar) == (Foo[int], float)\n\n assert Baz.__bases__ == (list,)\n assert get_original_bases(Baz) == (list[str],)\n\n assert Eggs.__bases__ == (tuple,)\n assert get_original_bases(Eggs) == (NamedTuple,)\n\n assert Spam.__bases__ == (dict,)\n assert get_original_bases(Spam) == (TypedDict,)\n\n assert int.__bases__ == (object,)\n assert get_original_bases(int) == (object,)\n\n .. versionadded:: 3.12\n\n.. seealso::\n\n :pep:`560` - Core support for typing module and generic types\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:14505:17983"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-head0,dp-Python-library-types.rst,Python 3.13.0 documentation: Additional Utility Classes and Functions,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with :class:`!SimpleNamespace` you can add and remove\n attributes.\n\n :py:class:`SimpleNamespace` objects may be initialized\n in the same way as :class:`dict`: either with keyword arguments,\n with a single positional argument, or with both.\n When initialized with keyword arguments,\n those are directly added to the underlying namespace.\n Alternatively, when initialized with a positional argument,\n the underlying namespace will be updated with key-value pairs\n from that argument (either a mapping object or\n an :term:`iterable` object producing key-value pairs).\n All such keys must be strings.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, mapping_or_iterable=(), /, **kwargs):\n self.__dict__.update(mapping_or_iterable)\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n :class:`!SimpleNamespace` objects are supported by :func:`copy.replace`.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n .. versionchanged:: 3.13\n Added support for an optional positional argument.\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n.. class:: CapsuleType\n\n The type of :ref:`capsule objects `.\n\n .. versionadded:: 3.13\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:14505:17983"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-head1,dp-Python-library-types.rst,Python 3.13.0 documentation: Standard Interpreter Types,"[""Standard Interpreter Types\n--------------------------\n\nThis module provides names for many of the types that are required to\nimplement a Python interpreter. It deliberately avoids including some of\nthe types that arise only incidentally during processing such as the\n``listiterator`` type.\n\nTypical use of these names is for :func:`isinstance` or\n:func:`issubclass` checks.\n\n\nIf you instantiate any of these types, note that signatures may vary between Python versions.\n\nStandard names are defined for the following types:\n\n.. data:: NoneType\n\n The type of :data:`None`.\n\n .. versionadded:: 3.10\n\n\n.. data:: FunctionType\n LambdaType\n\n The type of user-defined functions and functions created by\n :keyword:`lambda` expressions.\n\n .. audit-event:: function.__new__ code types.FunctionType\n\n The audit event only occurs for direct instantiation of function objects,\n and is not raised for normal compilation.\n\n\n.. data:: GeneratorType\n\n The type of :term:`generator`-iterator objects, created by\n generator functions.\n\n\n.. data:: CoroutineType\n\n The type of :term:`coroutine` objects, created by\n :keyword:`async def` functions.\n\n .. versionadded:: 3.5\n\n\n.. data:: AsyncGeneratorType\n\n The type of :term:`asynchronous generator`-iterator objects, created by\n asynchronous generator functions.\n\n .. versionadded:: 3.6\n\n\n.. class:: CodeType(**kwargs)\n\n .. index:: pair: built-in function; compile\n\n The type of :ref:`code objects ` such as returned by :func:`compile`.\n\n .. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType\n\n Note that the audited arguments may not match the names or positions\n required by the initializer. The audit event only occurs for direct\n instantiation of code objects, and is not raised for normal compilation.\n\n.. data:: CellType\n\n The type for cell objects: such objects are used as containers for\n a function's free variables.\n\n .. versionadded:: 3.8\n\n\n.. data:: MethodType\n\n The type of methods of user-defined class instances.\n\n\n.. data:: BuiltinFunctionType\n BuiltinMethodType\n\n The type of built-in functions like :func:`len` or :func:`sys.exit`, and\n methods of built-in classes. (Here, the term \""built-in\"" means \""written in\n C\"".)\n\n\n.. data:: WrapperDescriptorType\n\n The type of methods of some built-in data types and base classes such as\n :meth:`object.__init__` or :meth:`object.__lt__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: MethodWrapperType\n\n The type of *bound* methods of some built-in data types and base classes.\n For example it is the type of :code:`object().__str__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: NotImplementedType\n\n The type of :data:`NotImplemented`.\n\n .. versionadded:: 3.10\n\n\n.. data:: MethodDescriptorType\n\n The type of methods of some built-in data types such as :meth:`str.join`.\n\n .. versionadded:: 3.7\n\n\n.. data:: ClassMethodDescriptorType\n\n The type of *unbound* class methods of some built-in data types such as\n ``dict.__dict__['fromkeys']``.\n\n .. versionadded:: 3.7\n\n\n.. class:: ModuleType(name, doc=None)\n\n The type of :term:`modules `. The constructor takes the name of the\n module to be created and optionally its :term:`docstring`.\n\n .. note::\n Use :func:`importlib.util.module_from_spec` to create a new module if you\n wish to set the various import-controlled attributes.\n\n .. attribute:: __doc__\n\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n.. class:: CapsuleType\n\n The type of :ref:`capsule objects `.\n\n .. versionadded:: 3.13\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:4510:8290"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-head2,dp-Python-library-types.rst,Python 3.13.0 documentation: Coroutine Utility Functions,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with :class:`!SimpleNamespace` you can add and remove\n attributes.\n\n :py:class:`SimpleNamespace` objects may be initialized\n in the same way as :class:`dict`: either with keyword arguments,\n with a single positional argument, or with both.\n When initialized with keyword arguments,\n those are directly added to the underlying namespace.\n Alternatively, when initialized with a positional argument,\n the underlying namespace will be updated with key-value pairs\n from that argument (either a mapping object or\n an :term:`iterable` object producing key-value pairs).\n All such keys must be strings.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, mapping_or_iterable=(), /, **kwargs):\n self.__dict__.update(mapping_or_iterable)\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n :class:`!SimpleNamespace` objects are supported by :func:`copy.replace`.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n .. versionchanged:: 3.13\n Added support for an optional positional argument.\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","["":mod:`!types` --- Dynamic type creation and names for built-in types\n====================================================================\n\n.. module:: types\n :synopsis: Names for built-in types.\n\n**Source code:** :source:`Lib/types.py`\n\n--------------\n\nThis module defines utility functions to assist in dynamic creation of\nnew types.\n\nIt also defines names for some object types that are used by the standard\nPython interpreter, but not exposed as builtins like :class:`int` or\n:class:`str` are.\n\nFinally, it provides some additional type-related utility classes and functions\nthat are not fundamental enough to be builtins.\n\n\n"", ""Standard Interpreter Types\n--------------------------\n\nThis module provides names for many of the types that are required to\nimplement a Python interpreter. It deliberately avoids including some of\nthe types that arise only incidentally during processing such as the\n``listiterator`` type.\n\nTypical use of these names is for :func:`isinstance` or\n:func:`issubclass` checks.\n\n\nIf you instantiate any of these types, note that signatures may vary between Python versions.\n\nStandard names are defined for the following types:\n\n.. data:: NoneType\n\n The type of :data:`None`.\n\n .. versionadded:: 3.10\n\n\n.. data:: FunctionType\n LambdaType\n\n The type of user-defined functions and functions created by\n :keyword:`lambda` expressions.\n\n .. audit-event:: function.__new__ code types.FunctionType\n\n The audit event only occurs for direct instantiation of function objects,\n and is not raised for normal compilation.\n\n\n.. data:: GeneratorType\n\n The type of :term:`generator`-iterator objects, created by\n generator functions.\n\n\n.. data:: CoroutineType\n\n The type of :term:`coroutine` objects, created by\n :keyword:`async def` functions.\n\n .. versionadded:: 3.5\n\n\n.. data:: AsyncGeneratorType\n\n The type of :term:`asynchronous generator`-iterator objects, created by\n asynchronous generator functions.\n\n .. versionadded:: 3.6\n\n\n.. class:: CodeType(**kwargs)\n\n .. index:: pair: built-in function; compile\n\n The type of :ref:`code objects ` such as returned by :func:`compile`.\n\n .. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType\n\n Note that the audited arguments may not match the names or positions\n required by the initializer. The audit event only occurs for direct\n instantiation of code objects, and is not raised for normal compilation.\n\n.. data:: CellType\n\n The type for cell objects: such objects are used as containers for\n a function's free variables.\n\n .. versionadded:: 3.8\n\n\n.. data:: MethodType\n\n The type of methods of user-defined class instances.\n\n\n.. data:: BuiltinFunctionType\n BuiltinMethodType\n\n The type of built-in functions like :func:`len` or :func:`sys.exit`, and\n methods of built-in classes. (Here, the term \""built-in\"" means \""written in\n C\"".)\n\n\n.. data:: WrapperDescriptorType\n\n The type of methods of some built-in data types and base classes such as\n :meth:`object.__init__` or :meth:`object.__lt__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: MethodWrapperType\n\n The type of *bound* methods of some built-in data types and base classes.\n For example it is the type of :code:`object().__str__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: NotImplementedType\n\n The type of :data:`NotImplemented`.\n\n .. versionadded:: 3.10\n\n\n.. data:: MethodDescriptorType\n\n The type of methods of some built-in data types such as :meth:`str.join`.\n\n .. versionadded:: 3.7\n\n\n.. data:: ClassMethodDescriptorType\n\n The type of *unbound* class methods of some built-in data types such as\n ``dict.__dict__['fromkeys']``.\n\n .. versionadded:: 3.7\n\n\n.. class:: ModuleType(name, doc=None)\n\n The type of :term:`modules `. The constructor takes the name of the\n module to be created and optionally its :term:`docstring`.\n\n .. note::\n Use :func:`importlib.util.module_from_spec` to create a new module if you\n wish to set the various import-controlled attributes.\n\n .. attribute:: __doc__\n\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:14505:17983"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-library-types.rst-none0,dp-Python-library-types.rst,What is the signature of types.CoroutineType_strict in Python 3.13.0?,[],"[""Standard Interpreter Types\n--------------------------\n\nThis module provides names for many of the types that are required to\nimplement a Python interpreter. It deliberately avoids including some of\nthe types that arise only incidentally during processing such as the\n``listiterator`` type.\n\nTypical use of these names is for :func:`isinstance` or\n:func:`issubclass` checks.\n\n\nIf you instantiate any of these types, note that signatures may vary between Python versions.\n\nStandard names are defined for the following types:\n\n.. data:: NoneType\n\n The type of :data:`None`.\n\n .. versionadded:: 3.10\n\n\n.. data:: FunctionType\n LambdaType\n\n The type of user-defined functions and functions created by\n :keyword:`lambda` expressions.\n\n .. audit-event:: function.__new__ code types.FunctionType\n\n The audit event only occurs for direct instantiation of function objects,\n and is not raised for normal compilation.\n\n\n.. data:: GeneratorType\n\n The type of :term:`generator`-iterator objects, created by\n generator functions.\n\n\n.. data:: CoroutineType\n\n The type of :term:`coroutine` objects, created by\n :keyword:`async def` functions.\n\n .. versionadded:: 3.5\n\n\n.. data:: AsyncGeneratorType\n\n The type of :term:`asynchronous generator`-iterator objects, created by\n asynchronous generator functions.\n\n .. versionadded:: 3.6\n\n\n.. class:: CodeType(**kwargs)\n\n .. index:: pair: built-in function; compile\n\n The type of :ref:`code objects ` such as returned by :func:`compile`.\n\n .. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType\n\n Note that the audited arguments may not match the names or positions\n required by the initializer. The audit event only occurs for direct\n instantiation of code objects, and is not raised for normal compilation.\n\n.. data:: CellType\n\n The type for cell objects: such objects are used as containers for\n a function's free variables.\n\n .. versionadded:: 3.8\n\n\n.. data:: MethodType\n\n The type of methods of user-defined class instances.\n\n\n.. data:: BuiltinFunctionType\n BuiltinMethodType\n\n The type of built-in functions like :func:`len` or :func:`sys.exit`, and\n methods of built-in classes. (Here, the term \""built-in\"" means \""written in\n C\"".)\n\n\n.. data:: WrapperDescriptorType\n\n The type of methods of some built-in data types and base classes such as\n :meth:`object.__init__` or :meth:`object.__lt__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: MethodWrapperType\n\n The type of *bound* methods of some built-in data types and base classes.\n For example it is the type of :code:`object().__str__`.\n\n .. versionadded:: 3.7\n\n\n.. data:: NotImplementedType\n\n The type of :data:`NotImplemented`.\n\n .. versionadded:: 3.10\n\n\n.. data:: MethodDescriptorType\n\n The type of methods of some built-in data types such as :meth:`str.join`.\n\n .. versionadded:: 3.7\n\n\n.. data:: ClassMethodDescriptorType\n\n The type of *unbound* class methods of some built-in data types such as\n ``dict.__dict__['fromkeys']``.\n\n .. versionadded:: 3.7\n\n\n.. class:: ModuleType(name, doc=None)\n\n The type of :term:`modules `. The constructor takes the name of the\n module to be created and optionally its :term:`docstring`.\n\n .. note::\n Use :func:`importlib.util.module_from_spec` to create a new module if you\n wish to set the various import-controlled attributes.\n\n .. attribute:: __doc__\n\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/library/types.rst#codepoints:4510:8290"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym0,dp-Python-library-types.rst,What is the signature of types.GenericAlias in Python 3.12.7?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]","[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:7992:14403"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym1,dp-Python-library-types.rst,Python 3.12.7: what does types.MappingProxyType do?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]","[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:7992:14403"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym2,dp-Python-library-types.rst,Python 3.12.7: what does types.MappingProxyType.keys do?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]","[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:7992:14403"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym3,dp-Python-library-types.rst,What is the signature of types.DynamicClassAttribute in Python 3.12.7?,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:14403:17210"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym4,dp-Python-library-types.rst,Python 3.12.7: what does types.SimpleNamespace do?,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:14403:17210"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-sym5,dp-Python-library-types.rst,Python 3.12.7: what does types.FrameType do?,"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]","[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:7992:14403"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-head0,dp-Python-library-types.rst,Python 3.12.7 documentation: Additional Utility Classes and Functions,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:14403:17210"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-head1,dp-Python-library-types.rst,Python 3.12.7 documentation: Coroutine Utility Functions,"[""Additional Utility Classes and Functions\n----------------------------------------\n\n.. class:: SimpleNamespace\n\n A simple :class:`object` subclass that provides attribute access to its\n namespace, as well as a meaningful repr.\n\n Unlike :class:`object`, with ``SimpleNamespace`` you can add and remove\n attributes. If a ``SimpleNamespace`` object is initialized with keyword\n arguments, those are directly added to the underlying namespace.\n\n The type is roughly equivalent to the following code::\n\n class SimpleNamespace:\n def __init__(self, /, **kwargs):\n self.__dict__.update(kwargs)\n\n def __repr__(self):\n items = (f\""{k}={v!r}\"" for k, v in self.__dict__.items())\n return \""{}({})\"".format(type(self).__name__, \"", \"".join(items))\n\n def __eq__(self, other):\n if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):\n return self.__dict__ == other.__dict__\n return NotImplemented\n\n ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.\n However, for a structured record type use :func:`~collections.namedtuple`\n instead.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n Attribute order in the repr changed from alphabetical to insertion (like\n ``dict``).\n\n.. function:: DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)\n\n Route attribute access on a class to __getattr__.\n\n This is a descriptor, used to define attributes that act differently when\n accessed through an instance and through a class. Instance access remains\n normal, but access to an attribute through a class will be routed to the\n class's __getattr__ method; this is done by raising AttributeError.\n\n This allows one to have properties active on an instance, and have virtual\n attributes on the class with the same name (see :class:`enum.Enum` for an example).\n\n .. versionadded:: 3.4\n\n\nCoroutine Utility Functions\n---------------------------\n\n.. function:: coroutine(gen_func)\n\n This function transforms a :term:`generator` function into a\n :term:`coroutine function` which returns a generator-based coroutine.\n The generator-based coroutine is still a :term:`generator iterator`,\n but is also considered to be a :term:`coroutine` object and is\n :term:`awaitable`. However, it may not necessarily implement\n the :meth:`~object.__await__` method.\n\n If *gen_func* is a generator function, it will be modified in-place.\n\n If *gen_func* is not a generator function, it will be wrapped. If it\n returns an instance of :class:`collections.abc.Generator`, the instance\n will be wrapped in an *awaitable* proxy object. All other types\n of objects will be returned as is.\n\n .. versionadded:: 3.5\n""]","[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:14403:17210"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-library-types.rst-none0,dp-Python-library-types.rst,What is the signature of types.GenericAlias_strict in Python 3.12.7?,[],"[""\n The :term:`docstring` of the module. Defaults to ``None``.\n\n .. attribute:: __loader__\n\n The :term:`loader` which loaded the module. Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.loader`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__loader__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __name__\n\n The name of the module. Expected to match\n :attr:`importlib.machinery.ModuleSpec.name`.\n\n .. attribute:: __package__\n\n Which :term:`package` a module belongs to. If the module is top-level\n (i.e. not a part of any specific package) then the attribute should be set\n to ``''``, else it should be set to the name of the package (which can be\n :attr:`__name__` if the module is a package itself). Defaults to ``None``.\n\n This attribute is to match :attr:`importlib.machinery.ModuleSpec.parent`\n as stored in the :attr:`__spec__` object.\n\n .. note::\n A future version of Python may stop setting this attribute by default.\n To guard against this potential change, preferably read from the\n :attr:`__spec__` attribute instead or use\n ``getattr(module, \""__package__\"", None)`` if you explicitly need to use\n this attribute.\n\n .. versionchanged:: 3.4\n Defaults to ``None``. Previously the attribute was optional.\n\n .. attribute:: __spec__\n\n A record of the module's import-system-related state. Expected to be an\n instance of :class:`importlib.machinery.ModuleSpec`.\n\n .. versionadded:: 3.4\n\n\n.. data:: EllipsisType\n\n The type of :data:`Ellipsis`.\n\n .. versionadded:: 3.10\n\n.. class:: GenericAlias(t_origin, t_args)\n\n The type of :ref:`parameterized generics ` such as\n ``list[int]``.\n\n ``t_origin`` should be a non-parameterized generic class, such as ``list``,\n ``tuple`` or ``dict``. ``t_args`` should be a :class:`tuple` (possibly of\n length 1) of types which parameterize ``t_origin``::\n\n >>> from types import GenericAlias\n\n >>> list[int] == GenericAlias(list, (int,))\n True\n >>> dict[str, int] == GenericAlias(dict, (str, int))\n True\n\n .. versionadded:: 3.9\n\n .. versionchanged:: 3.9.2\n This type can now be subclassed.\n\n .. seealso::\n\n :ref:`Generic Alias Types`\n In-depth documentation on instances of :class:`!types.GenericAlias`\n\n :pep:`585` - Type Hinting Generics In Standard Collections\n Introducing the :class:`!types.GenericAlias` class\n\n.. class:: UnionType\n\n The type of :ref:`union type expressions`.\n\n .. versionadded:: 3.10\n\n.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n\n The type of traceback objects such as found in ``sys.exception().__traceback__``.\n\n See :ref:`the language reference ` for details of the\n available attributes and operations, and guidance on creating tracebacks\n dynamically.\n\n\n.. data:: FrameType\n\n The type of :ref:`frame objects ` such as found in\n :attr:`tb.tb_frame ` if ``tb`` is a traceback object.\n\n\n.. data:: GetSetDescriptorType\n\n The type of objects defined in extension modules with ``PyGetSetDef``, such\n as :attr:`FrameType.f_locals ` or ``array.array.typecode``.\n This type is used as\n descriptor for object attributes; it has the same purpose as the\n :class:`property` type, but for classes defined in extension modules.\n\n\n.. data:: MemberDescriptorType\n\n The type of objects defined in extension modules with ``PyMemberDef``, such\n as ``datetime.timedelta.days``. This type is used as descriptor for simple C\n data members which use standard conversion functions; it has the same purpose\n as the :class:`property` type, but for classes defined in extension modules.\n\n In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for\n each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute\n on the class. This allows the slot to appear in the class's :attr:`~type.__dict__`.\n\n .. impl-detail::\n\n In other implementations of Python, this type may be identical to\n ``GetSetDescriptorType``.\n\n.. class:: MappingProxyType(mapping)\n\n Read-only proxy of a mapping. It provides a dynamic view on the mapping's\n entries, which means that when the mapping changes, the view reflects these\n changes.\n\n .. versionadded:: 3.3\n\n .. versionchanged:: 3.9\n\n Updated to support the new union (``|``) operator from :pep:`584`, which\n simply delegates to the underlying mapping.\n\n .. describe:: key in proxy\n\n Return ``True`` if the underlying mapping has a key *key*, else\n ``False``.\n\n .. describe:: proxy[key]\n\n Return the item of the underlying mapping with key *key*. Raises a\n :exc:`KeyError` if *key* is not in the underlying mapping.\n\n .. describe:: iter(proxy)\n\n Return an iterator over the keys of the underlying mapping. This is a\n shortcut for ``iter(proxy.keys())``.\n\n .. describe:: len(proxy)\n\n Return the number of items in the underlying mapping.\n\n .. method:: copy()\n\n Return a shallow copy of the underlying mapping.\n\n .. method:: get(key[, default])\n\n Return the value for *key* if *key* is in the underlying mapping, else\n *default*. If *default* is not given, it defaults to ``None``, so that\n this method never raises a :exc:`KeyError`.\n\n .. method:: items()\n\n Return a new view of the underlying mapping's items (``(key, value)``\n pairs).\n\n .. method:: keys()\n\n Return a new view of the underlying mapping's keys.\n\n .. method:: values()\n\n Return a new view of the underlying mapping's values.\n\n .. describe:: reversed(proxy)\n\n Return a reverse iterator over the keys of the underlying mapping.\n\n .. versionadded:: 3.9\n\n .. describe:: hash(proxy)\n\n Return a hash of the underlying mapping.\n\n .. versionadded:: 3.12\n\n\n""]",unanswerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/library/types.rst#codepoints:7992:14403"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:library/types.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.13-tutorial-inputoutput.rst-head0,dp-Python-tutorial-inputoutput.rst,Python 3.13.0 documentation: The String format() Method,"[""The String format() Method\n--------------------------\n\nBasic usage of the :meth:`str.format` method looks like this::\n\n >>> print('We are the {} who say \""{}!\""'.format('knights', 'Ni'))\n We are the knights who say \""Ni!\""\n\nThe brackets and characters within them (called format fields) are replaced with\nthe objects passed into the :meth:`str.format` method. A number in the\nbrackets can be used to refer to the position of the object passed into the\n:meth:`str.format` method. ::\n\n >>> print('{0} and {1}'.format('spam', 'eggs'))\n spam and eggs\n >>> print('{1} and {0}'.format('spam', 'eggs'))\n eggs and spam\n\nIf keyword arguments are used in the :meth:`str.format` method, their values\nare referred to by using the name of the argument. ::\n\n >>> print('This {food} is {adjective}.'.format(\n ... food='spam', adjective='absolutely horrible'))\n This spam is absolutely horrible.\n\nPositional and keyword arguments can be arbitrarily combined::\n\n >>> print('The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred',\n ... other='Georg'))\n The story of Bill, Manfred, and Georg.\n\nIf you have a really long format string that you don't want to split up, it\nwould be nice if you could reference the variables to be formatted by name\ninstead of by position. This can be done by simply passing the dict and using\nsquare brackets ``'[]'`` to access the keys. ::\n\n >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n >>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '\n ... 'Dcab: {0[Dcab]:d}'.format(table))\n Jack: 4098; Sjoerd: 4127; Dcab: 8637678\n\nThis could also be done by passing the ``table`` dictionary as keyword arguments with the ``**``\nnotation. ::\n\n >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n >>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))\n Jack: 4098; Sjoerd: 4127; Dcab: 8637678\n\nThis is particularly useful in combination with the built-in function\n:func:`vars`, which returns a dictionary containing all local variables::\n\n >>> table = {k: str(v) for k, v in vars().items()}\n >>> message = \"" \"".join([f'{k}: ' + '{' + k +'};' for k in table.keys()])\n >>> print(message.format(**table))\n __name__: __main__; __doc__: None; __package__: None; __loader__: ...\n\nAs an example, the following lines produce a tidily aligned\nset of columns giving integers and their squares and cubes::\n\n >>> for x in range(1, 11):\n ... print('{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x))\n ...\n 1 1 1\n 2 4 8\n 3 9 27\n 4 16 64\n 5 25 125\n 6 36 216\n 7 49 343\n 8 64 512\n 9 81 729\n 10 100 1000\n\nFor a complete overview of string formatting with :meth:`str.format`, see\n:ref:`formatstrings`.\n\n\n""]","[""Fancier Output Formatting\n=========================\n\nSo far we've encountered two ways of writing values: *expression statements* and\nthe :func:`print` function. (A third way is using the :meth:`~io.TextIOBase.write` method\nof file objects; the standard output file can be referenced as ``sys.stdout``.\nSee the Library Reference for more information on this.)\n\nOften you'll want more control over the formatting of your output than simply\nprinting space-separated values. There are several ways to format output.\n\n* To use :ref:`formatted string literals `, begin a string\n with ``f`` or ``F`` before the opening quotation mark or triple quotation mark.\n Inside this string, you can write a Python expression between ``{`` and ``}``\n characters that can refer to variables or literal values.\n\n ::\n\n >>> year = 2016\n >>> event = 'Referendum'\n >>> f'Results of the {year} {event}'\n 'Results of the 2016 Referendum'\n\n* The :meth:`str.format` method of strings requires more manual\n effort. You'll still use ``{`` and ``}`` to mark where a variable\n will be substituted and can provide detailed formatting directives,\n but you'll also need to provide the information to be formatted. In the following code\n block there are two examples of how to format variables:\n\n\n ::\n\n >>> yes_votes = 42_572_654\n >>> total_votes = 85_705_149\n >>> percentage = yes_votes / total_votes\n >>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n ' 42572654 YES votes 49.67%'\n\n Notice how the ``yes_votes`` are padded with spaces and a negative sign only for negative numbers.\n The example also prints ``percentage`` multiplied by 100, with 2 decimal\n places and followed by a percent sign (see :ref:`formatspec` for details).\n\n\n* Finally, you can do all the string handling yourself by using string slicing and\n concatenation operations to create any layout you can imagine. The\n string type has some methods that perform useful operations for padding\n strings to a given column width.\n\nWhen you don't need fancy output but just want a quick display of some\nvariables for debugging purposes, you can convert any value to a string with\nthe :func:`repr` or :func:`str` functions.\n\nThe :func:`str` function is meant to return representations of values which are\nfairly human-readable, while :func:`repr` is meant to generate representations\nwhich can be read by the interpreter (or will force a :exc:`SyntaxError` if\nthere is no equivalent syntax). For objects which don't have a particular\nrepresentation for human consumption, :func:`str` will return the same value as\n:func:`repr`. Many values, such as numbers or structures like lists and\ndictionaries, have the same representation using either function. Strings, in\nparticular, have two distinct representations.\n\nSome examples::\n\n >>> s = 'Hello, world.'\n >>> str(s)\n 'Hello, world.'\n >>> repr(s)\n \""'Hello, world.'\""\n >>> str(1/7)\n '0.14285714285714285'\n >>> x = 10 * 3.25\n >>> y = 200 * 200\n >>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'\n >>> print(s)\n The value of x is 32.5, and y is 40000...\n >>> # The repr() of a string adds string quotes and backslashes:\n >>> hello = 'hello, world\\n'\n >>> hellos = repr(hello)\n >>> print(hellos)\n 'hello, world\\n'\n >>> # The argument to repr() may be any Python object:\n >>> repr((x, y, ('spam', 'eggs')))\n \""(32.5, 40000, ('spam', 'eggs'))\""\n\nThe :mod:`string` module contains a :class:`~string.Template` class that offers\nyet another way to substitute values into strings, using placeholders like\n``$x`` and replacing them with values from a dictionary, but offers much less\ncontrol of the formatting.\n\n\n.. _tut-f-strings:\n\n"", ""Saving structured data with :mod:`json`\n---------------------------------------\n\n.. index:: pair: module; json\n\nStrings can easily be written to and read from a file. Numbers take a bit more\neffort, since the :meth:`~io.TextIOBase.read` method only returns strings, which will have to\nbe passed to a function like :func:`int`, which takes a string like ``'123'``\nand returns its numeric value 123. When you want to save more complex data\ntypes like nested lists and dictionaries, parsing and serializing by hand\nbecomes complicated.\n\nRather than having users constantly writing and debugging code to save\ncomplicated data types to files, Python allows you to use the popular data\ninterchange format called `JSON (JavaScript Object Notation)\n`_. The standard module called :mod:`json` can take Python\ndata hierarchies, and convert them to string representations; this process is\ncalled :dfn:`serializing`. Reconstructing the data from the string representation\nis called :dfn:`deserializing`. Between serializing and deserializing, the\nstring representing the object may have been stored in a file or data, or\nsent over a network connection to some distant machine.\n\n.. note::\n The JSON format is commonly used by modern applications to allow for data\n exchange. Many programmers are already familiar with it, which makes\n it a good choice for interoperability.\n\nIf you have an object ``x``, you can view its JSON string representation with a\nsimple line of code::\n\n >>> import json\n >>> x = [1, 'simple', 'list']\n >>> json.dumps(x)\n '[1, \""simple\"", \""list\""]'\n\nAnother variant of the :func:`~json.dumps` function, called :func:`~json.dump`,\nsimply serializes the object to a :term:`text file`. So if ``f`` is a\n:term:`text file` object opened for writing, we can do this::\n\n json.dump(x, f)\n\nTo decode the object again, if ``f`` is a :term:`binary file` or\n:term:`text file` object which has been opened for reading::\n\n x = json.load(f)\n\n.. note::\n JSON files must be encoded in UTF-8. Use ``encoding=\""utf-8\""`` when opening\n JSON file as a :term:`text file` for both of reading and writing.\n\nThis simple serialization technique can handle lists and dictionaries, but\nserializing arbitrary class instances in JSON requires a bit of extra effort.\nThe reference for the :mod:`json` module contains an explanation of this.\n\n.. seealso::\n\n :mod:`pickle` - the pickle module\n\n Contrary to :ref:`JSON `, *pickle* is a protocol which allows\n the serialization of arbitrarily complex Python objects. As such, it is\n specific to Python and cannot be used to communicate with applications\n written in other languages. It is also insecure by default:\n deserializing pickle data coming from an untrusted source can execute\n arbitrary code, if the data was crafted by a skilled attacker.\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/tutorial/inputoutput.rst#codepoints:5957:8768"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:tutorial/inputoutput.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-tutorial-inputoutput.rst-head1,dp-Python-tutorial-inputoutput.rst,Python 3.13.0 documentation: Manual String Formatting,"[""Manual String Formatting\n------------------------\n\nHere's the same table of squares and cubes, formatted manually::\n\n >>> for x in range(1, 11):\n ... print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')\n ... # Note use of 'end' on previous line\n ... print(repr(x*x*x).rjust(4))\n ...\n 1 1 1\n 2 4 8\n 3 9 27\n 4 16 64\n 5 25 125\n 6 36 216\n 7 49 343\n 8 64 512\n 9 81 729\n 10 100 1000\n\n(Note that the one space between each column was added by the\nway :func:`print` works: it always adds spaces between its arguments.)\n\nThe :meth:`str.rjust` method of string objects right-justifies a string in a\nfield of a given width by padding it with spaces on the left. There are\nsimilar methods :meth:`str.ljust` and :meth:`str.center`. These methods do\nnot write anything, they just return a new string. If the input string is too\nlong, they don't truncate it, but return it unchanged; this will mess up your\ncolumn lay-out but that's usually better than the alternative, which would be\nlying about a value. (If you really want truncation you can always add a\nslice operation, as in ``x.ljust(n)[:n]``.)\n\nThere is another method, :meth:`str.zfill`, which pads a numeric string on the\nleft with zeros. It understands about plus and minus signs::\n\n >>> '12'.zfill(5)\n '00012'\n >>> '-3.14'.zfill(7)\n '-003.14'\n >>> '3.14159265359'.zfill(5)\n '3.14159265359'\n\n\nOld string formatting\n---------------------\n\nThe % operator (modulo) can also be used for string formatting.\nGiven ``format % values`` (where *format* is a string),\n``%`` conversion specifications in *format* are replaced with\nzero or more elements of *values*.\nThis operation is commonly known as string\ninterpolation. For example::\n\n >>> import math\n >>> print('The value of pi is approximately %5.3f.' % math.pi)\n The value of pi is approximately 3.142.\n\nMore information can be found in the :ref:`old-string-formatting` section.\n\n\n.. _tut-files:\n\n""]","[""Fancier Output Formatting\n=========================\n\nSo far we've encountered two ways of writing values: *expression statements* and\nthe :func:`print` function. (A third way is using the :meth:`~io.TextIOBase.write` method\nof file objects; the standard output file can be referenced as ``sys.stdout``.\nSee the Library Reference for more information on this.)\n\nOften you'll want more control over the formatting of your output than simply\nprinting space-separated values. There are several ways to format output.\n\n* To use :ref:`formatted string literals `, begin a string\n with ``f`` or ``F`` before the opening quotation mark or triple quotation mark.\n Inside this string, you can write a Python expression between ``{`` and ``}``\n characters that can refer to variables or literal values.\n\n ::\n\n >>> year = 2016\n >>> event = 'Referendum'\n >>> f'Results of the {year} {event}'\n 'Results of the 2016 Referendum'\n\n* The :meth:`str.format` method of strings requires more manual\n effort. You'll still use ``{`` and ``}`` to mark where a variable\n will be substituted and can provide detailed formatting directives,\n but you'll also need to provide the information to be formatted. In the following code\n block there are two examples of how to format variables:\n\n\n ::\n\n >>> yes_votes = 42_572_654\n >>> total_votes = 85_705_149\n >>> percentage = yes_votes / total_votes\n >>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n ' 42572654 YES votes 49.67%'\n\n Notice how the ``yes_votes`` are padded with spaces and a negative sign only for negative numbers.\n The example also prints ``percentage`` multiplied by 100, with 2 decimal\n places and followed by a percent sign (see :ref:`formatspec` for details).\n\n\n* Finally, you can do all the string handling yourself by using string slicing and\n concatenation operations to create any layout you can imagine. The\n string type has some methods that perform useful operations for padding\n strings to a given column width.\n\nWhen you don't need fancy output but just want a quick display of some\nvariables for debugging purposes, you can convert any value to a string with\nthe :func:`repr` or :func:`str` functions.\n\nThe :func:`str` function is meant to return representations of values which are\nfairly human-readable, while :func:`repr` is meant to generate representations\nwhich can be read by the interpreter (or will force a :exc:`SyntaxError` if\nthere is no equivalent syntax). For objects which don't have a particular\nrepresentation for human consumption, :func:`str` will return the same value as\n:func:`repr`. Many values, such as numbers or structures like lists and\ndictionaries, have the same representation using either function. Strings, in\nparticular, have two distinct representations.\n\nSome examples::\n\n >>> s = 'Hello, world.'\n >>> str(s)\n 'Hello, world.'\n >>> repr(s)\n \""'Hello, world.'\""\n >>> str(1/7)\n '0.14285714285714285'\n >>> x = 10 * 3.25\n >>> y = 200 * 200\n >>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'\n >>> print(s)\n The value of x is 32.5, and y is 40000...\n >>> # The repr() of a string adds string quotes and backslashes:\n >>> hello = 'hello, world\\n'\n >>> hellos = repr(hello)\n >>> print(hellos)\n 'hello, world\\n'\n >>> # The argument to repr() may be any Python object:\n >>> repr((x, y, ('spam', 'eggs')))\n \""(32.5, 40000, ('spam', 'eggs'))\""\n\nThe :mod:`string` module contains a :class:`~string.Template` class that offers\nyet another way to substitute values into strings, using placeholders like\n``$x`` and replacing them with values from a dictionary, but offers much less\ncontrol of the formatting.\n\n\n.. _tut-f-strings:\n\n"", ""Formatted String Literals\n-------------------------\n\n:ref:`Formatted string literals ` (also called f-strings for\nshort) let you include the value of Python expressions inside a string by\nprefixing the string with ``f`` or ``F`` and writing expressions as\n``{expression}``.\n\nAn optional format specifier can follow the expression. This allows greater\ncontrol over how the value is formatted. The following example rounds pi to\nthree places after the decimal::\n\n >>> import math\n >>> print(f'The value of pi is approximately {math.pi:.3f}.')\n The value of pi is approximately 3.142.\n\nPassing an integer after the ``':'`` will cause that field to be a minimum\nnumber of characters wide. This is useful for making columns line up. ::\n\n >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n >>> for name, phone in table.items():\n ... print(f'{name:10} ==> {phone:10d}')\n ...\n Sjoerd ==> 4127\n Jack ==> 4098\n Dcab ==> 7678\n\nOther modifiers can be used to convert the value before it is formatted.\n``'!a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'``\napplies :func:`repr`::\n\n >>> animals = 'eels'\n >>> print(f'My hovercraft is full of {animals}.')\n My hovercraft is full of eels.\n >>> print(f'My hovercraft is full of {animals!r}.')\n My hovercraft is full of 'eels'.\n\nThe ``=`` specifier can be used to expand an expression to the text of the\nexpression, an equal sign, then the representation of the evaluated expression:\n\n >>> bugs = 'roaches'\n >>> count = 13\n >>> area = 'living room'\n >>> print(f'Debugging {bugs=} {count=} {area=}')\n Debugging bugs='roaches' count=13 area='living room'\n\nSee :ref:`self-documenting expressions ` for more information\non the ``=`` specifier. For a reference on these format specifications, see\nthe reference guide for the :ref:`formatspec`.\n\n.. _tut-string-format:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/tutorial/inputoutput.rst#codepoints:8768:10755"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:tutorial/inputoutput.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-tutorial-inputoutput.rst-head2,dp-Python-tutorial-inputoutput.rst,Python 3.13.0 documentation: Old string formatting,"[""Manual String Formatting\n------------------------\n\nHere's the same table of squares and cubes, formatted manually::\n\n >>> for x in range(1, 11):\n ... print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')\n ... # Note use of 'end' on previous line\n ... print(repr(x*x*x).rjust(4))\n ...\n 1 1 1\n 2 4 8\n 3 9 27\n 4 16 64\n 5 25 125\n 6 36 216\n 7 49 343\n 8 64 512\n 9 81 729\n 10 100 1000\n\n(Note that the one space between each column was added by the\nway :func:`print` works: it always adds spaces between its arguments.)\n\nThe :meth:`str.rjust` method of string objects right-justifies a string in a\nfield of a given width by padding it with spaces on the left. There are\nsimilar methods :meth:`str.ljust` and :meth:`str.center`. These methods do\nnot write anything, they just return a new string. If the input string is too\nlong, they don't truncate it, but return it unchanged; this will mess up your\ncolumn lay-out but that's usually better than the alternative, which would be\nlying about a value. (If you really want truncation you can always add a\nslice operation, as in ``x.ljust(n)[:n]``.)\n\nThere is another method, :meth:`str.zfill`, which pads a numeric string on the\nleft with zeros. It understands about plus and minus signs::\n\n >>> '12'.zfill(5)\n '00012'\n >>> '-3.14'.zfill(7)\n '-003.14'\n >>> '3.14159265359'.zfill(5)\n '3.14159265359'\n\n\nOld string formatting\n---------------------\n\nThe % operator (modulo) can also be used for string formatting.\nGiven ``format % values`` (where *format* is a string),\n``%`` conversion specifications in *format* are replaced with\nzero or more elements of *values*.\nThis operation is commonly known as string\ninterpolation. For example::\n\n >>> import math\n >>> print('The value of pi is approximately %5.3f.' % math.pi)\n The value of pi is approximately 3.142.\n\nMore information can be found in the :ref:`old-string-formatting` section.\n\n\n.. _tut-files:\n\n""]","[""Fancier Output Formatting\n=========================\n\nSo far we've encountered two ways of writing values: *expression statements* and\nthe :func:`print` function. (A third way is using the :meth:`~io.TextIOBase.write` method\nof file objects; the standard output file can be referenced as ``sys.stdout``.\nSee the Library Reference for more information on this.)\n\nOften you'll want more control over the formatting of your output than simply\nprinting space-separated values. There are several ways to format output.\n\n* To use :ref:`formatted string literals `, begin a string\n with ``f`` or ``F`` before the opening quotation mark or triple quotation mark.\n Inside this string, you can write a Python expression between ``{`` and ``}``\n characters that can refer to variables or literal values.\n\n ::\n\n >>> year = 2016\n >>> event = 'Referendum'\n >>> f'Results of the {year} {event}'\n 'Results of the 2016 Referendum'\n\n* The :meth:`str.format` method of strings requires more manual\n effort. You'll still use ``{`` and ``}`` to mark where a variable\n will be substituted and can provide detailed formatting directives,\n but you'll also need to provide the information to be formatted. In the following code\n block there are two examples of how to format variables:\n\n\n ::\n\n >>> yes_votes = 42_572_654\n >>> total_votes = 85_705_149\n >>> percentage = yes_votes / total_votes\n >>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n ' 42572654 YES votes 49.67%'\n\n Notice how the ``yes_votes`` are padded with spaces and a negative sign only for negative numbers.\n The example also prints ``percentage`` multiplied by 100, with 2 decimal\n places and followed by a percent sign (see :ref:`formatspec` for details).\n\n\n* Finally, you can do all the string handling yourself by using string slicing and\n concatenation operations to create any layout you can imagine. The\n string type has some methods that perform useful operations for padding\n strings to a given column width.\n\nWhen you don't need fancy output but just want a quick display of some\nvariables for debugging purposes, you can convert any value to a string with\nthe :func:`repr` or :func:`str` functions.\n\nThe :func:`str` function is meant to return representations of values which are\nfairly human-readable, while :func:`repr` is meant to generate representations\nwhich can be read by the interpreter (or will force a :exc:`SyntaxError` if\nthere is no equivalent syntax). For objects which don't have a particular\nrepresentation for human consumption, :func:`str` will return the same value as\n:func:`repr`. Many values, such as numbers or structures like lists and\ndictionaries, have the same representation using either function. Strings, in\nparticular, have two distinct representations.\n\nSome examples::\n\n >>> s = 'Hello, world.'\n >>> str(s)\n 'Hello, world.'\n >>> repr(s)\n \""'Hello, world.'\""\n >>> str(1/7)\n '0.14285714285714285'\n >>> x = 10 * 3.25\n >>> y = 200 * 200\n >>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'\n >>> print(s)\n The value of x is 32.5, and y is 40000...\n >>> # The repr() of a string adds string quotes and backslashes:\n >>> hello = 'hello, world\\n'\n >>> hellos = repr(hello)\n >>> print(hellos)\n 'hello, world\\n'\n >>> # The argument to repr() may be any Python object:\n >>> repr((x, y, ('spam', 'eggs')))\n \""(32.5, 40000, ('spam', 'eggs'))\""\n\nThe :mod:`string` module contains a :class:`~string.Template` class that offers\nyet another way to substitute values into strings, using placeholders like\n``$x`` and replacing them with values from a dictionary, but offers much less\ncontrol of the formatting.\n\n\n.. _tut-f-strings:\n\n"", ""Formatted String Literals\n-------------------------\n\n:ref:`Formatted string literals ` (also called f-strings for\nshort) let you include the value of Python expressions inside a string by\nprefixing the string with ``f`` or ``F`` and writing expressions as\n``{expression}``.\n\nAn optional format specifier can follow the expression. This allows greater\ncontrol over how the value is formatted. The following example rounds pi to\nthree places after the decimal::\n\n >>> import math\n >>> print(f'The value of pi is approximately {math.pi:.3f}.')\n The value of pi is approximately 3.142.\n\nPassing an integer after the ``':'`` will cause that field to be a minimum\nnumber of characters wide. This is useful for making columns line up. ::\n\n >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n >>> for name, phone in table.items():\n ... print(f'{name:10} ==> {phone:10d}')\n ...\n Sjoerd ==> 4127\n Jack ==> 4098\n Dcab ==> 7678\n\nOther modifiers can be used to convert the value before it is formatted.\n``'!a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'``\napplies :func:`repr`::\n\n >>> animals = 'eels'\n >>> print(f'My hovercraft is full of {animals}.')\n My hovercraft is full of eels.\n >>> print(f'My hovercraft is full of {animals!r}.')\n My hovercraft is full of 'eels'.\n\nThe ``=`` specifier can be used to expand an expression to the text of the\nexpression, an equal sign, then the representation of the evaluated expression:\n\n >>> bugs = 'roaches'\n >>> count = 13\n >>> area = 'living room'\n >>> print(f'Debugging {bugs=} {count=} {area=}')\n Debugging bugs='roaches' count=13 area='living room'\n\nSee :ref:`self-documenting expressions ` for more information\non the ``=`` specifier. For a reference on these format specifications, see\nthe reference guide for the :ref:`formatspec`.\n\n.. _tut-string-format:\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/tutorial/inputoutput.rst#codepoints:8768:10755"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:tutorial/inputoutput.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-whatsnew-3.10.rst-head0,dp-Python-whatsnew-3.10.rst,Python 3.13.0 documentation: Patterns with positional parameters,"[""Patterns with a literal and variable\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nPatterns can look like unpacking assignments, and a pattern may be used to bind\nvariables. In this example, a data point can be unpacked to its x-coordinate\nand y-coordinate::\n\n # point is an (x, y) tuple\n match point:\n case (0, 0):\n print(\""Origin\"")\n case (0, y):\n print(f\""Y={y}\"")\n case (x, 0):\n print(f\""X={x}\"")\n case (x, y):\n print(f\""X={x}, Y={y}\"")\n case _:\n raise ValueError(\""Not a point\"")\n\nThe first pattern has two literals, ``(0, 0)``, and may be thought of as an\nextension of the literal pattern shown above. The next two patterns combine a\nliteral and a variable, and the variable *binds* a value from the subject\n(``point``). The fourth pattern captures two values, which makes it\nconceptually similar to the unpacking assignment ``(x, y) = point``.\n\nPatterns and classes\n~~~~~~~~~~~~~~~~~~~~\n\nIf you are using classes to structure your data, you can use as a pattern\nthe class name followed by an argument list resembling a constructor. This\npattern has the ability to capture class attributes into variables::\n\n class Point:\n x: int\n y: int\n\n def location(point):\n match point:\n case Point(x=0, y=0):\n print(\""Origin is the point's location.\"")\n case Point(x=0, y=y):\n print(f\""Y={y} and the point is on the y-axis.\"")\n case Point(x=x, y=0):\n print(f\""X={x} and the point is on the x-axis.\"")\n case Point():\n print(\""The point is located somewhere else on the plane.\"")\n case _:\n print(\""Not a point\"")\n\nPatterns with positional parameters\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou can use positional parameters with some builtin classes that provide an\nordering for their attributes (e.g. dataclasses). You can also define a specific\nposition for attributes in patterns by setting the ``__match_args__`` special\nattribute in your classes. If it's set to (\""x\"", \""y\""), the following patterns\nare all equivalent (and all bind the ``y`` attribute to the ``var`` variable)::\n\n Point(1, var)\n Point(1, y=var)\n Point(x=1, y=var)\n Point(y=var, x=1)\n\nNested patterns\n~~~~~~~~~~~~~~~\n\nPatterns can be arbitrarily nested. For example, if our data is a short\nlist of points, it could be matched like this::\n\n match points:\n case []:\n print(\""No points in the list.\"")\n case [Point(0, 0)]:\n print(\""The origin is the only point in the list.\"")\n case [Point(x, y)]:\n print(f\""A single point {x}, {y} is in the list.\"")\n case [Point(0, y1), Point(0, y2)]:\n print(f\""Two points on the Y axis at {y1}, {y2} are in the list.\"")\n case _:\n print(\""Something else is found in the list.\"")\n\nComplex patterns and the wildcard\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo this point, the examples have used ``_`` alone in the last case statement.\nA wildcard can be used in more complex patterns, such as ``('error', code, _)``.\nFor example::\n\n match test_variable:\n case ('warning', code, 40):\n print(\""A warning has been received.\"")\n case ('error', code, _):\n print(f\""An error {code} occurred.\"")\n\nIn the above case, ``test_variable`` will match for ('error', code, 100) and\n('error', code, 800).\n\nGuard\n~~~~~\n\nWe can add an ``if`` clause to a pattern, known as a \""guard\"". If the\nguard is false, ``match`` goes on to try the next case block. Note\nthat value capture happens before the guard is evaluated::\n\n match point:\n case Point(x, y) if x == y:\n print(f\""The point is located on the diagonal Y=X at {x}.\"")\n case Point(x, y):\n print(f\""Point is not on the diagonal.\"")\n\n""]","[""traceback\n---------\n\nThe :func:`~traceback.format_exception`,\n:func:`~traceback.format_exception_only`, and\n:func:`~traceback.print_exception` functions can now take an exception object\nas a positional-only argument.\n(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)\n\ntypes\n-----\n\nReintroduce the :data:`types.EllipsisType`, :data:`types.NoneType`\nand :data:`types.NotImplementedType` classes, providing a new set\nof types readily interpretable by type checkers.\n(Contributed by Bas van Beek in :issue:`41810`.)\n\ntyping\n------\n\nFor major changes, see :ref:`new-feat-related-type-hints`.\n\nThe behavior of :class:`typing.Literal` was changed to conform with :pep:`586`\nand to match the behavior of static type checkers specified in the PEP.\n\n1. ``Literal`` now de-duplicates parameters.\n2. Equality comparisons between ``Literal`` objects are now order independent.\n3. ``Literal`` comparisons now respect types. For example,\n ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is\n now ``False``. To support this change, the internally used type cache now\n supports differentiating types.\n4. ``Literal`` objects will now raise a :exc:`TypeError` exception during\n equality comparisons if any of their parameters are not :term:`hashable`.\n Note that declaring ``Literal`` with unhashable parameters will not throw\n an error::\n\n >>> from typing import Literal\n >>> Literal[{0}]\n >>> Literal[{0}] == Literal[{False}]\n Traceback (most recent call last):\n File \""\"", line 1, in \n TypeError: unhashable type: 'set'\n\n(Contributed by Yurii Karabas in :issue:`42345`.)\n\nAdd new function :func:`typing.is_typeddict` to introspect if an annotation\nis a :class:`typing.TypedDict`.\n(Contributed by Patrick Reader in :issue:`41792`.)\n\nSubclasses of ``typing.Protocol`` which only have data variables declared\nwill now raise a ``TypeError`` when checked with ``isinstance`` unless they\nare decorated with :func:`~typing.runtime_checkable`. Previously, these checks\npassed silently. Users should decorate their\nsubclasses with the :func:`!runtime_checkable` decorator\nif they want runtime protocols.\n(Contributed by Yurii Karabas in :issue:`38908`.)\n\nImporting from the ``typing.io`` and ``typing.re`` submodules will now emit\n:exc:`DeprecationWarning`. These submodules have been deprecated since\nPython 3.8 and will be removed in a future version of Python. Anything\nbelonging to those submodules should be imported directly from\n:mod:`typing` instead.\n(Contributed by Sebastian Rittau in :issue:`38291`.)\n\nunittest\n--------\n\nAdd new method :meth:`~unittest.TestCase.assertNoLogs` to complement the\nexisting :meth:`~unittest.TestCase.assertLogs`. (Contributed by Kit Yan Choi\nin :issue:`39385`.)\n\nurllib.parse\n------------\n\nPython versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as\nquery parameter separators in :func:`urllib.parse.parse_qs` and\n:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with\nnewer W3C recommendations, this has been changed to allow only a single\nseparator key, with ``&`` as the default. This change also affects\n:func:`!cgi.parse` and :func:`!cgi.parse_multipart` as they use the affected\nfunctions internally. For more details, please see their respective\ndocumentation.\n(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)\n\nThe presence of newline or tab characters in parts of a URL allows for some\nforms of attacks. Following the WHATWG specification that updates :rfc:`3986`,\nASCII newline ``\\n``, ``\\r`` and tab ``\\t`` characters are stripped from the\nURL by the parser in :mod:`urllib.parse` preventing such attacks. The removal\ncharacters are controlled by a new module level variable\n``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. (See :gh:`88048`)\n\n"", ""PEP 604: New Type Union Operator\n--------------------------------\n\nA new type union operator was introduced which enables the syntax ``X | Y``.\nThis provides a cleaner way of expressing 'either type X or type Y' instead of\nusing :data:`typing.Union`, especially in type hints.\n\nIn previous versions of Python, to apply a type hint for functions accepting\narguments of multiple types, :data:`typing.Union` was used::\n\n def square(number: Union[int, float]) -> Union[int, float]:\n return number ** 2\n\n\nType hints can now be written in a more succinct manner::\n\n def square(number: int | float) -> int | float:\n return number ** 2\n\n\nThis new syntax is also accepted as the second argument to :func:`isinstance`\nand :func:`issubclass`::\n\n >>> isinstance(1, int | str)\n True\n\nSee :ref:`types-union` and :pep:`604` for more details.\n\n(Contributed by Maggie Moss and Philippe Prados in :issue:`41428`,\nwith additions by Yurii Karabas and Serhiy Storchaka in :issue:`44490`.)\n\n\nPEP 612: Parameter Specification Variables\n------------------------------------------\n\nTwo new options to improve the information provided to static type checkers for\n:pep:`484`\\ 's ``Callable`` have been added to the :mod:`typing` module.\n\nThe first is the parameter specification variable. They are used to forward the\nparameter types of one callable to another callable -- a pattern commonly\nfound in higher order functions and decorators. Examples of usage can be found\nin :class:`typing.ParamSpec`. Previously, there was no easy way to type annotate\ndependency of parameter types in such a precise manner.\n\nThe second option is the new ``Concatenate`` operator. It's used in conjunction\nwith parameter specification variables to type annotate a higher order callable\nwhich adds or removes parameters of another callable. Examples of usage can\nbe found in :class:`typing.Concatenate`.\n\nSee :class:`typing.Callable`, :class:`typing.ParamSpec`,\n:class:`typing.Concatenate`, :class:`typing.ParamSpecArgs`,\n:class:`typing.ParamSpecKwargs`, and :pep:`612` for more details.\n\n(Contributed by Ken Jin in :issue:`41559`, with minor enhancements by Jelle\nZijlstra in :issue:`43783`. PEP written by Mark Mendoza.)\n\n\nPEP 613: TypeAlias\n------------------\n\n:pep:`484` introduced the concept of type aliases, only requiring them to be\ntop-level unannotated assignments. This simplicity sometimes made it difficult\nfor type checkers to distinguish between type aliases and ordinary assignments,\nespecially when forward references or invalid types were involved. Compare::\n\n StrCache = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nNow the :mod:`typing` module has a special value :data:`~typing.TypeAlias`\nwhich lets you declare type aliases more explicitly::\n\n StrCache: TypeAlias = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nSee :pep:`613` for more details.\n\n(Contributed by Mikhail Golubev in :issue:`41923`.)\n\nPEP 647: User-Defined Type Guards\n---------------------------------\n\n:data:`~typing.TypeGuard` has been added to the :mod:`typing` module to annotate\ntype guard functions and improve information provided to static type checkers\nduring type narrowing. For more information, please see\n:data:`~typing.TypeGuard`\\ 's documentation, and :pep:`647`.\n\n(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`.\nPEP written by Eric Traut.)\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/whatsnew/3.10.rst#codepoints:16736:20574"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-whatsnew-3.10.rst-head1,dp-Python-whatsnew-3.10.rst,Python 3.13.0 documentation: New Features,"[""****************************\n What's New In Python 3.10\n****************************\n\n:Editor: Pablo Galindo Salgado\n\n.. Rules for maintenance:\n\n * Anyone can add text to this document. Do not spend very much time\n on the wording of your changes, because your text will probably\n get rewritten to some degree.\n\n * The maintainer will go through Misc/NEWS periodically and add\n changes; it's therefore more important to add your changes to\n Misc/NEWS than to this file.\n\n * This is not a complete list of every single change; completeness\n is the purpose of Misc/NEWS. Some changes I consider too small\n or esoteric to include. If such a change is added to the text,\n I'll just remove it. (This is another reason you shouldn't spend\n too much time on writing your addition.)\n\n * If you want to draw your new text to the attention of the\n maintainer, add 'XXX' to the beginning of the paragraph or\n section.\n\n * It's OK to just add a fragmentary note about a change. For\n example: \""XXX Describe the transmogrify() function added to the\n socket module.\"" The maintainer will research the change and\n write the necessary text.\n\n * You can comment out your additions if you like, but it's not\n necessary (especially when a final release is some months away).\n\n * Credit the author of a patch or bugfix. Just the name is\n sufficient; the e-mail address isn't necessary.\n\n * It's helpful to add the bug/patch number as a comment:\n\n XXX Describe the transmogrify() function added to the socket\n module.\n (Contributed by P.Y. Developer in :issue:`12345`.)\n\n This saves the maintainer the effort of going through the git log\n when researching a change.\n\nThis article explains the new features in Python 3.10, compared to 3.9.\nPython 3.10 was released on October 4, 2021.\nFor full details, see the :ref:`changelog `.\n\nSummary -- Release highlights\n=============================\n\n.. This section singles out the most important changes in Python 3.10.\n Brevity is key.\n\n\n.. PEP-sized items next.\n\nNew syntax features:\n\n* :pep:`634`, Structural Pattern Matching: Specification\n* :pep:`635`, Structural Pattern Matching: Motivation and Rationale\n* :pep:`636`, Structural Pattern Matching: Tutorial\n* :issue:`12782`, Parenthesized context managers are now officially allowed.\n\nNew features in the standard library:\n\n* :pep:`618`, Add Optional Length-Checking To zip.\n\nInterpreter improvements:\n\n* :pep:`626`, Precise line numbers for debugging and other tools.\n\nNew typing features:\n\n* :pep:`604`, Allow writing union types as X | Y\n* :pep:`612`, Parameter Specification Variables\n* :pep:`613`, Explicit Type Aliases\n* :pep:`647`, User-Defined Type Guards\n\nImportant deprecations, removals or restrictions:\n\n* :pep:`644`, Require OpenSSL 1.1.1 or newer\n* :pep:`632`, Deprecate distutils module.\n* :pep:`623`, Deprecate and prepare for the removal of the wstr member in PyUnicodeObject.\n* :pep:`624`, Remove Py_UNICODE encoder APIs\n* :pep:`597`, Add optional EncodingWarning\n\n\nNew Features\n============\n\n.. _whatsnew310-pep563:\n\n""]","[""Notable security feature in 3.10.7\n==================================\n\nConverting between :class:`int` and :class:`str` in bases other than 2\n(binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal)\nnow raises a :exc:`ValueError` if the number of digits in string form is\nabove a limit to avoid potential denial of service attacks due to the\nalgorithmic complexity. This is a mitigation for :cve:`2020-10735`.\nThis limit can be configured or disabled by environment variable, command\nline flag, or :mod:`sys` APIs. See the :ref:`integer string conversion\nlength limitation ` documentation. The default limit\nis 4300 digits in string form.\n\nNotable security feature in 3.10.8\n==================================\n\nThe deprecated :mod:`!mailcap` module now refuses to inject unsafe text\n(filenames, MIME types, parameters) into shell commands. Instead of using such\ntext, it will warn and act as if a match was not found (or for test commands,\nas if the test failed).\n(Contributed by Petr Viktorin in :gh:`98966`.)\n\nNotable changes in 3.10.12\n==========================\n\ntarfile\n-------\n\n* The extraction methods in :mod:`tarfile`, and :func:`shutil.unpack_archive`,\n have a new a *filter* argument that allows limiting tar features than may be\n surprising or dangerous, such as creating files outside the destination\n directory.\n See :ref:`tarfile-extraction-filter` for details.\n In Python 3.12, use without the *filter* argument will show a\n :exc:`DeprecationWarning`.\n In Python 3.14, the default will switch to ``'data'``.\n (Contributed by Petr Viktorin in :pep:`706`.)\n"", ""PEP 604: New Type Union Operator\n--------------------------------\n\nA new type union operator was introduced which enables the syntax ``X | Y``.\nThis provides a cleaner way of expressing 'either type X or type Y' instead of\nusing :data:`typing.Union`, especially in type hints.\n\nIn previous versions of Python, to apply a type hint for functions accepting\narguments of multiple types, :data:`typing.Union` was used::\n\n def square(number: Union[int, float]) -> Union[int, float]:\n return number ** 2\n\n\nType hints can now be written in a more succinct manner::\n\n def square(number: int | float) -> int | float:\n return number ** 2\n\n\nThis new syntax is also accepted as the second argument to :func:`isinstance`\nand :func:`issubclass`::\n\n >>> isinstance(1, int | str)\n True\n\nSee :ref:`types-union` and :pep:`604` for more details.\n\n(Contributed by Maggie Moss and Philippe Prados in :issue:`41428`,\nwith additions by Yurii Karabas and Serhiy Storchaka in :issue:`44490`.)\n\n\nPEP 612: Parameter Specification Variables\n------------------------------------------\n\nTwo new options to improve the information provided to static type checkers for\n:pep:`484`\\ 's ``Callable`` have been added to the :mod:`typing` module.\n\nThe first is the parameter specification variable. They are used to forward the\nparameter types of one callable to another callable -- a pattern commonly\nfound in higher order functions and decorators. Examples of usage can be found\nin :class:`typing.ParamSpec`. Previously, there was no easy way to type annotate\ndependency of parameter types in such a precise manner.\n\nThe second option is the new ``Concatenate`` operator. It's used in conjunction\nwith parameter specification variables to type annotate a higher order callable\nwhich adds or removes parameters of another callable. Examples of usage can\nbe found in :class:`typing.Concatenate`.\n\nSee :class:`typing.Callable`, :class:`typing.ParamSpec`,\n:class:`typing.Concatenate`, :class:`typing.ParamSpecArgs`,\n:class:`typing.ParamSpecKwargs`, and :pep:`612` for more details.\n\n(Contributed by Ken Jin in :issue:`41559`, with minor enhancements by Jelle\nZijlstra in :issue:`43783`. PEP written by Mark Mendoza.)\n\n\nPEP 613: TypeAlias\n------------------\n\n:pep:`484` introduced the concept of type aliases, only requiring them to be\ntop-level unannotated assignments. This simplicity sometimes made it difficult\nfor type checkers to distinguish between type aliases and ordinary assignments,\nespecially when forward references or invalid types were involved. Compare::\n\n StrCache = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nNow the :mod:`typing` module has a special value :data:`~typing.TypeAlias`\nwhich lets you declare type aliases more explicitly::\n\n StrCache: TypeAlias = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nSee :pep:`613` for more details.\n\n(Contributed by Mikhail Golubev in :issue:`41923`.)\n\nPEP 647: User-Defined Type Guards\n---------------------------------\n\n:data:`~typing.TypeGuard` has been added to the :mod:`typing` module to annotate\ntype guard functions and improve information provided to static type checkers\nduring type narrowing. For more information, please see\n:data:`~typing.TypeGuard`\\ 's documentation, and :pep:`647`.\n\n(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`.\nPEP written by Eric Traut.)\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/whatsnew/3.10.rst#codepoints:0:3089"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.13-whatsnew-3.10.rst-head2,dp-Python-whatsnew-3.10.rst,Python 3.13.0 documentation: New Features,"[""New Features\n------------\n\n* The result of :c:func:`PyNumber_Index` now always has exact type :class:`int`.\n Previously, the result could have been an instance of a subclass of ``int``.\n (Contributed by Serhiy Storchaka in :issue:`40792`.)\n\n* Add a new :c:member:`~PyConfig.orig_argv` member to the :c:type:`PyConfig`\n structure: the list of the original command line arguments passed to the\n Python executable.\n (Contributed by Victor Stinner in :issue:`23427`.)\n\n* The :c:func:`PyDateTime_DATE_GET_TZINFO` and\n :c:func:`PyDateTime_TIME_GET_TZINFO` macros have been added for accessing\n the ``tzinfo`` attributes of :class:`datetime.datetime` and\n :class:`datetime.time` objects.\n (Contributed by Zackery Spytz in :issue:`30155`.)\n\n* Add a :c:func:`PyCodec_Unregister` function to unregister a codec\n search function.\n (Contributed by Hai Shi in :issue:`41842`.)\n\n* The :c:func:`PyIter_Send` function was added to allow\n sending value into iterator without raising ``StopIteration`` exception.\n (Contributed by Vladimir Matveev in :issue:`41756`.)\n\n* Add :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API.\n (Contributed by Alex Gaynor in :issue:`41784`.)\n\n* Add :c:func:`PyModule_AddObjectRef` function: similar to\n :c:func:`PyModule_AddObject` but don't steal a reference to the value on\n success.\n (Contributed by Victor Stinner in :issue:`1635741`.)\n\n* Add :c:func:`Py_NewRef` and :c:func:`Py_XNewRef` functions to increment the\n reference count of an object and return the object.\n (Contributed by Victor Stinner in :issue:`42262`.)\n\n* The :c:func:`PyType_FromSpecWithBases` and :c:func:`PyType_FromModuleAndSpec`\n functions now accept a single class as the *bases* argument.\n (Contributed by Serhiy Storchaka in :issue:`42423`.)\n\n* The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc``\n slot.\n (Contributed by Hai Shi in :issue:`41832`.)\n\n* The :c:func:`PyType_GetSlot` function can accept\n :ref:`static types `.\n (Contributed by Hai Shi and Petr Viktorin in :issue:`41073`.)\n\n* Add a new :c:func:`PySet_CheckExact` function to the C-API to check if an\n object is an instance of :class:`set` but not an instance of a subtype.\n (Contributed by Pablo Galindo in :issue:`43277`.)\n\n* Add :c:func:`PyErr_SetInterruptEx` which allows passing a signal number\n to simulate.\n (Contributed by Antoine Pitrou in :issue:`43356`.)\n\n* The limited C API is now supported if :ref:`Python is built in debug mode\n ` (if the ``Py_DEBUG`` macro is defined). In the limited C API,\n the :c:func:`Py_INCREF` and :c:func:`Py_DECREF` functions are now implemented\n as opaque function\n calls, rather than accessing directly the :c:member:`PyObject.ob_refcnt`\n member, if Python is built in debug mode and the ``Py_LIMITED_API`` macro\n targets Python 3.10 or newer. It became possible to support the limited C API\n in debug mode because the :c:type:`PyObject` structure is the same in release\n and debug mode since Python 3.8 (see :issue:`36465`).\n\n The limited C API is still not supported in the :option:`--with-trace-refs`\n special build (``Py_TRACE_REFS`` macro).\n (Contributed by Victor Stinner in :issue:`43688`.)\n\n* Add the :c:func:`Py_Is(x, y) ` function to test if the *x* object is\n the *y* object, the same as ``x is y`` in Python. Add also the\n :c:func:`Py_IsNone`, :c:func:`Py_IsTrue`, :c:func:`Py_IsFalse` functions to\n test if an object is, respectively, the ``None`` singleton, the ``True``\n singleton or the ``False`` singleton.\n (Contributed by Victor Stinner in :issue:`43753`.)\n\n* Add new functions to control the garbage collector from C code:\n :c:func:`PyGC_Enable()`,\n :c:func:`PyGC_Disable()`,\n :c:func:`PyGC_IsEnabled()`.\n These functions allow to activate, deactivate and query the state of the garbage collector from C code without\n having to import the :mod:`gc` module.\n\n* Add a new :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` type flag to disallow\n creating type instances.\n (Contributed by Victor Stinner in :issue:`43916`.)\n\n* Add a new :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` type flag for creating immutable\n type objects: type attributes cannot be set nor deleted.\n (Contributed by Victor Stinner and Erlend E. Aasland in :issue:`43908`.)\n\n""]","[""Notable security feature in 3.10.7\n==================================\n\nConverting between :class:`int` and :class:`str` in bases other than 2\n(binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal)\nnow raises a :exc:`ValueError` if the number of digits in string form is\nabove a limit to avoid potential denial of service attacks due to the\nalgorithmic complexity. This is a mitigation for :cve:`2020-10735`.\nThis limit can be configured or disabled by environment variable, command\nline flag, or :mod:`sys` APIs. See the :ref:`integer string conversion\nlength limitation ` documentation. The default limit\nis 4300 digits in string form.\n\nNotable security feature in 3.10.8\n==================================\n\nThe deprecated :mod:`!mailcap` module now refuses to inject unsafe text\n(filenames, MIME types, parameters) into shell commands. Instead of using such\ntext, it will warn and act as if a match was not found (or for test commands,\nas if the test failed).\n(Contributed by Petr Viktorin in :gh:`98966`.)\n\nNotable changes in 3.10.12\n==========================\n\ntarfile\n-------\n\n* The extraction methods in :mod:`tarfile`, and :func:`shutil.unpack_archive`,\n have a new a *filter* argument that allows limiting tar features than may be\n surprising or dangerous, such as creating files outside the destination\n directory.\n See :ref:`tarfile-extraction-filter` for details.\n In Python 3.12, use without the *filter* argument will show a\n :exc:`DeprecationWarning`.\n In Python 3.14, the default will switch to ``'data'``.\n (Contributed by Petr Viktorin in :pep:`706`.)\n"", ""PEP 604: New Type Union Operator\n--------------------------------\n\nA new type union operator was introduced which enables the syntax ``X | Y``.\nThis provides a cleaner way of expressing 'either type X or type Y' instead of\nusing :data:`typing.Union`, especially in type hints.\n\nIn previous versions of Python, to apply a type hint for functions accepting\narguments of multiple types, :data:`typing.Union` was used::\n\n def square(number: Union[int, float]) -> Union[int, float]:\n return number ** 2\n\n\nType hints can now be written in a more succinct manner::\n\n def square(number: int | float) -> int | float:\n return number ** 2\n\n\nThis new syntax is also accepted as the second argument to :func:`isinstance`\nand :func:`issubclass`::\n\n >>> isinstance(1, int | str)\n True\n\nSee :ref:`types-union` and :pep:`604` for more details.\n\n(Contributed by Maggie Moss and Philippe Prados in :issue:`41428`,\nwith additions by Yurii Karabas and Serhiy Storchaka in :issue:`44490`.)\n\n\nPEP 612: Parameter Specification Variables\n------------------------------------------\n\nTwo new options to improve the information provided to static type checkers for\n:pep:`484`\\ 's ``Callable`` have been added to the :mod:`typing` module.\n\nThe first is the parameter specification variable. They are used to forward the\nparameter types of one callable to another callable -- a pattern commonly\nfound in higher order functions and decorators. Examples of usage can be found\nin :class:`typing.ParamSpec`. Previously, there was no easy way to type annotate\ndependency of parameter types in such a precise manner.\n\nThe second option is the new ``Concatenate`` operator. It's used in conjunction\nwith parameter specification variables to type annotate a higher order callable\nwhich adds or removes parameters of another callable. Examples of usage can\nbe found in :class:`typing.Concatenate`.\n\nSee :class:`typing.Callable`, :class:`typing.ParamSpec`,\n:class:`typing.Concatenate`, :class:`typing.ParamSpecArgs`,\n:class:`typing.ParamSpecKwargs`, and :pep:`612` for more details.\n\n(Contributed by Ken Jin in :issue:`41559`, with minor enhancements by Jelle\nZijlstra in :issue:`43783`. PEP written by Mark Mendoza.)\n\n\nPEP 613: TypeAlias\n------------------\n\n:pep:`484` introduced the concept of type aliases, only requiring them to be\ntop-level unannotated assignments. This simplicity sometimes made it difficult\nfor type checkers to distinguish between type aliases and ordinary assignments,\nespecially when forward references or invalid types were involved. Compare::\n\n StrCache = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nNow the :mod:`typing` module has a special value :data:`~typing.TypeAlias`\nwhich lets you declare type aliases more explicitly::\n\n StrCache: TypeAlias = 'Cache[str]' # a type alias\n LOG_PREFIX = 'LOG[DEBUG]' # a module constant\n\nSee :pep:`613` for more details.\n\n(Contributed by Mikhail Golubev in :issue:`41923`.)\n\nPEP 647: User-Defined Type Guards\n---------------------------------\n\n:data:`~typing.TypeGuard` has been added to the :mod:`typing` module to annotate\ntype guard functions and improve information provided to static type checkers\nduring type narrowing. For more information, please see\n:data:`~typing.TypeGuard`\\ 's documentation, and :pep:`647`.\n\n(Contributed by Ken Jin and Guido van Rossum in :issue:`43766`.\nPEP written by Eric Traut.)\n\n""]",answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.13.0/Doc/whatsnew/3.10.rst#codepoints:78168:82434"", ""revision"": ""3.13.0+sha256:12445c7b3db3126c41190bfdc1c8239c39c719404e844babbd015a1bc3fafcd4"", ""source_id"": ""cpython-3.13:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz""}]" dp-rt-cpython-3.12-whatsnew-3.10.rst-head0,dp-Python-whatsnew-3.10.rst,Python 3.12.7 documentation: urllib.parse,"[""traceback\n---------\n\nThe :func:`~traceback.format_exception`,\n:func:`~traceback.format_exception_only`, and\n:func:`~traceback.print_exception` functions can now take an exception object\nas a positional-only argument.\n(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)\n\ntypes\n-----\n\nReintroduce the :data:`types.EllipsisType`, :data:`types.NoneType`\nand :data:`types.NotImplementedType` classes, providing a new set\nof types readily interpretable by type checkers.\n(Contributed by Bas van Beek in :issue:`41810`.)\n\ntyping\n------\n\nFor major changes, see :ref:`new-feat-related-type-hints`.\n\nThe behavior of :class:`typing.Literal` was changed to conform with :pep:`586`\nand to match the behavior of static type checkers specified in the PEP.\n\n1. ``Literal`` now de-duplicates parameters.\n2. Equality comparisons between ``Literal`` objects are now order independent.\n3. ``Literal`` comparisons now respect types. For example,\n ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is\n now ``False``. To support this change, the internally used type cache now\n supports differentiating types.\n4. ``Literal`` objects will now raise a :exc:`TypeError` exception during\n equality comparisons if any of their parameters are not :term:`hashable`.\n Note that declaring ``Literal`` with unhashable parameters will not throw\n an error::\n\n >>> from typing import Literal\n >>> Literal[{0}]\n >>> Literal[{0}] == Literal[{False}]\n Traceback (most recent call last):\n File \""\"", line 1, in \n TypeError: unhashable type: 'set'\n\n(Contributed by Yurii Karabas in :issue:`42345`.)\n\nAdd new function :func:`typing.is_typeddict` to introspect if an annotation\nis a :class:`typing.TypedDict`.\n(Contributed by Patrick Reader in :issue:`41792`.)\n\nSubclasses of ``typing.Protocol`` which only have data variables declared\nwill now raise a ``TypeError`` when checked with ``isinstance`` unless they\nare decorated with :func:`~typing.runtime_checkable`. Previously, these checks\npassed silently. Users should decorate their\nsubclasses with the :func:`!runtime_checkable` decorator\nif they want runtime protocols.\n(Contributed by Yurii Karabas in :issue:`38908`.)\n\nImporting from the ``typing.io`` and ``typing.re`` submodules will now emit\n:exc:`DeprecationWarning`. These submodules have been deprecated since\nPython 3.8 and will be removed in a future version of Python. Anything\nbelonging to those submodules should be imported directly from\n:mod:`typing` instead.\n(Contributed by Sebastian Rittau in :issue:`38291`.)\n\nunittest\n--------\n\nAdd new method :meth:`~unittest.TestCase.assertNoLogs` to complement the\nexisting :meth:`~unittest.TestCase.assertLogs`. (Contributed by Kit Yan Choi\nin :issue:`39385`.)\n\nurllib.parse\n------------\n\nPython versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as\nquery parameter separators in :func:`urllib.parse.parse_qs` and\n:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with\nnewer W3C recommendations, this has been changed to allow only a single\nseparator key, with ``&`` as the default. This change also affects\n:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected\nfunctions internally. For more details, please see their respective\ndocumentation.\n(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)\n\nThe presence of newline or tab characters in parts of a URL allows for some\nforms of attacks. Following the WHATWG specification that updates :rfc:`3986`,\nASCII newline ``\\n``, ``\\r`` and tab ``\\t`` characters are stripped from the\nURL by the parser in :mod:`urllib.parse` preventing such attacks. The removal\ncharacters are controlled by a new module level variable\n``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. (See :gh:`88048`)\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/whatsnew/3.10.rst#codepoints:50099:53949"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-whatsnew-3.10.rst-head1,dp-Python-whatsnew-3.10.rst,Python 3.12.7 documentation: unittest,"[""traceback\n---------\n\nThe :func:`~traceback.format_exception`,\n:func:`~traceback.format_exception_only`, and\n:func:`~traceback.print_exception` functions can now take an exception object\nas a positional-only argument.\n(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)\n\ntypes\n-----\n\nReintroduce the :data:`types.EllipsisType`, :data:`types.NoneType`\nand :data:`types.NotImplementedType` classes, providing a new set\nof types readily interpretable by type checkers.\n(Contributed by Bas van Beek in :issue:`41810`.)\n\ntyping\n------\n\nFor major changes, see :ref:`new-feat-related-type-hints`.\n\nThe behavior of :class:`typing.Literal` was changed to conform with :pep:`586`\nand to match the behavior of static type checkers specified in the PEP.\n\n1. ``Literal`` now de-duplicates parameters.\n2. Equality comparisons between ``Literal`` objects are now order independent.\n3. ``Literal`` comparisons now respect types. For example,\n ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is\n now ``False``. To support this change, the internally used type cache now\n supports differentiating types.\n4. ``Literal`` objects will now raise a :exc:`TypeError` exception during\n equality comparisons if any of their parameters are not :term:`hashable`.\n Note that declaring ``Literal`` with unhashable parameters will not throw\n an error::\n\n >>> from typing import Literal\n >>> Literal[{0}]\n >>> Literal[{0}] == Literal[{False}]\n Traceback (most recent call last):\n File \""\"", line 1, in \n TypeError: unhashable type: 'set'\n\n(Contributed by Yurii Karabas in :issue:`42345`.)\n\nAdd new function :func:`typing.is_typeddict` to introspect if an annotation\nis a :class:`typing.TypedDict`.\n(Contributed by Patrick Reader in :issue:`41792`.)\n\nSubclasses of ``typing.Protocol`` which only have data variables declared\nwill now raise a ``TypeError`` when checked with ``isinstance`` unless they\nare decorated with :func:`~typing.runtime_checkable`. Previously, these checks\npassed silently. Users should decorate their\nsubclasses with the :func:`!runtime_checkable` decorator\nif they want runtime protocols.\n(Contributed by Yurii Karabas in :issue:`38908`.)\n\nImporting from the ``typing.io`` and ``typing.re`` submodules will now emit\n:exc:`DeprecationWarning`. These submodules have been deprecated since\nPython 3.8 and will be removed in a future version of Python. Anything\nbelonging to those submodules should be imported directly from\n:mod:`typing` instead.\n(Contributed by Sebastian Rittau in :issue:`38291`.)\n\nunittest\n--------\n\nAdd new method :meth:`~unittest.TestCase.assertNoLogs` to complement the\nexisting :meth:`~unittest.TestCase.assertLogs`. (Contributed by Kit Yan Choi\nin :issue:`39385`.)\n\nurllib.parse\n------------\n\nPython versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as\nquery parameter separators in :func:`urllib.parse.parse_qs` and\n:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with\nnewer W3C recommendations, this has been changed to allow only a single\nseparator key, with ``&`` as the default. This change also affects\n:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected\nfunctions internally. For more details, please see their respective\ndocumentation.\n(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)\n\nThe presence of newline or tab characters in parts of a URL allows for some\nforms of attacks. Following the WHATWG specification that updates :rfc:`3986`,\nASCII newline ``\\n``, ``\\r`` and tab ``\\t`` characters are stripped from the\nURL by the parser in :mod:`urllib.parse` preventing such attacks. The removal\ncharacters are controlled by a new module level variable\n``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. (See :gh:`88048`)\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/whatsnew/3.10.rst#codepoints:50099:53949"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-cpython-3.12-whatsnew-3.10.rst-head2,dp-Python-whatsnew-3.10.rst,Python 3.12.7 documentation: traceback,"[""traceback\n---------\n\nThe :func:`~traceback.format_exception`,\n:func:`~traceback.format_exception_only`, and\n:func:`~traceback.print_exception` functions can now take an exception object\nas a positional-only argument.\n(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)\n\ntypes\n-----\n\nReintroduce the :data:`types.EllipsisType`, :data:`types.NoneType`\nand :data:`types.NotImplementedType` classes, providing a new set\nof types readily interpretable by type checkers.\n(Contributed by Bas van Beek in :issue:`41810`.)\n\ntyping\n------\n\nFor major changes, see :ref:`new-feat-related-type-hints`.\n\nThe behavior of :class:`typing.Literal` was changed to conform with :pep:`586`\nand to match the behavior of static type checkers specified in the PEP.\n\n1. ``Literal`` now de-duplicates parameters.\n2. Equality comparisons between ``Literal`` objects are now order independent.\n3. ``Literal`` comparisons now respect types. For example,\n ``Literal[0] == Literal[False]`` previously evaluated to ``True``. It is\n now ``False``. To support this change, the internally used type cache now\n supports differentiating types.\n4. ``Literal`` objects will now raise a :exc:`TypeError` exception during\n equality comparisons if any of their parameters are not :term:`hashable`.\n Note that declaring ``Literal`` with unhashable parameters will not throw\n an error::\n\n >>> from typing import Literal\n >>> Literal[{0}]\n >>> Literal[{0}] == Literal[{False}]\n Traceback (most recent call last):\n File \""\"", line 1, in \n TypeError: unhashable type: 'set'\n\n(Contributed by Yurii Karabas in :issue:`42345`.)\n\nAdd new function :func:`typing.is_typeddict` to introspect if an annotation\nis a :class:`typing.TypedDict`.\n(Contributed by Patrick Reader in :issue:`41792`.)\n\nSubclasses of ``typing.Protocol`` which only have data variables declared\nwill now raise a ``TypeError`` when checked with ``isinstance`` unless they\nare decorated with :func:`~typing.runtime_checkable`. Previously, these checks\npassed silently. Users should decorate their\nsubclasses with the :func:`!runtime_checkable` decorator\nif they want runtime protocols.\n(Contributed by Yurii Karabas in :issue:`38908`.)\n\nImporting from the ``typing.io`` and ``typing.re`` submodules will now emit\n:exc:`DeprecationWarning`. These submodules have been deprecated since\nPython 3.8 and will be removed in a future version of Python. Anything\nbelonging to those submodules should be imported directly from\n:mod:`typing` instead.\n(Contributed by Sebastian Rittau in :issue:`38291`.)\n\nunittest\n--------\n\nAdd new method :meth:`~unittest.TestCase.assertNoLogs` to complement the\nexisting :meth:`~unittest.TestCase.assertLogs`. (Contributed by Kit Yan Choi\nin :issue:`39385`.)\n\nurllib.parse\n------------\n\nPython versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as\nquery parameter separators in :func:`urllib.parse.parse_qs` and\n:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with\nnewer W3C recommendations, this has been changed to allow only a single\nseparator key, with ``&`` as the default. This change also affects\n:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected\nfunctions internally. For more details, please see their respective\ndocumentation.\n(Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in :issue:`42967`.)\n\nThe presence of newline or tab characters in parts of a URL allows for some\nforms of attacks. Following the WHATWG specification that updates :rfc:`3986`,\nASCII newline ``\\n``, ``\\r`` and tab ``\\t`` characters are stripped from the\nURL by the parser in :mod:`urllib.parse` preventing such attacks. The removal\ncharacters are controlled by a new module level variable\n``urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE``. (See :gh:`88048`)\n\n""]",[],answerable,"[{""license"": ""PSF-2.0"", ""locator"": ""Python-3.12.7/Doc/whatsnew/3.10.rst#codepoints:50099:53949"", ""revision"": ""3.12.7+sha256:73ac8fe780227bf371add8373c3079f42a0dc62deff8d612cd15a618082ab623"", ""source_id"": ""cpython-3.12:whatsnew/3.10.rst"", ""uri"": ""https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym0,dp-Werkzeug-datastructures.rst,What is the signature of werkzeug.datastructures.ImmutableOrderedMultiDict in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym1,dp-Werkzeug-datastructures.rst,What is the signature of werkzeug.datastructures.LanguageAccept in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym2,dp-Werkzeug-datastructures.rst,How is werkzeug.datastructures.ImmutableList documented in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym3,dp-Werkzeug-datastructures.rst,What is the signature of werkzeug.datastructures.RequestCacheControl in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym4,dp-Werkzeug-datastructures.rst,What is the signature of werkzeug.datastructures.Accept in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-sym5,dp-Werkzeug-datastructures.rst,How is werkzeug.datastructures.MIMEAccept documented in Werkzeug 3.1.9?,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-head0,dp-Werkzeug-datastructures.rst,Werkzeug 3.1.9 documentation: General Purpose,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-head1,dp-Werkzeug-datastructures.rst,Werkzeug 3.1.9 documentation: Data Structures,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-head2,dp-Werkzeug-datastructures.rst,Werkzeug 3.1.9 documentation: HTTP Related,"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-datastructures.rst-none0,dp-Werkzeug-datastructures.rst,What is the signature of werkzeug.datastructures.ImmutableOrderedMultiDict_strict in Werkzeug 3.1.9?,[],"[""===============\nData Structures\n===============\n\n.. module:: werkzeug.datastructures\n\nWerkzeug provides some subclasses of common Python objects to extend them\nwith additional features. Some of them are used to make them immutable, others\nare used to change some semantics to better work with HTTP.\n\nGeneral Purpose\n===============\n\n.. versionchanged:: 0.6\n The general purpose classes are now pickleable in each protocol as long\n as the contained objects are pickleable. This means that the\n :class:`FileMultiDict` won't be pickleable as soon as it contains a\n file.\n\n.. autoclass:: TypeConversionDict\n :members:\n\n.. autoclass:: ImmutableTypeConversionDict\n :members: copy\n\n.. autoclass:: MultiDict\n :members:\n :inherited-members:\n\n.. class:: OrderedMultiDict\n\n Works like a regular :class:`MultiDict` but preserves the\n order of the fields. To convert the ordered multi dict into a\n list you can use the :meth:`items` method and pass it ``multi=True``.\n\n In general an :class:`OrderedMultiDict` is an order of magnitude\n slower than a :class:`MultiDict`.\n\n .. admonition:: note\n\n Due to a limitation in Python you cannot convert an ordered\n multi dict into a regular dict by using ``dict(multidict)``.\n Instead you have to use the :meth:`to_dict` method, otherwise\n the internal bucket objects are exposed.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``MultiDict`` instead.\n\n.. class:: ImmutableOrderedMultiDict\n\n An immutable :class:`OrderedMultiDict`.\n\n .. deprecated:: 3.1\n Will be removed in Werkzeug 3.2. Use ``ImmutableMultiDict`` instead.\n\n .. versionadded:: 0.6\n\n.. autoclass:: CombinedMultiDict\n\n.. autoclass:: ImmutableDict\n :members: copy\n\n.. autoclass:: ImmutableList\n\n.. autoclass:: FileMultiDict\n :members:\n\n.. _http-datastructures:\n\nHTTP Related\n============\n\n.. autoclass:: Headers([defaults])\n :members:\n\n.. autoclass:: EnvironHeaders\n\n.. autoclass:: HeaderSet\n :members:\n\n.. autoclass:: Accept\n :members:\n\n.. autoclass:: MIMEAccept\n :members: accept_html, accept_xhtml, accept_json\n\n.. autoclass:: CharsetAccept\n\n.. autoclass:: LanguageAccept\n\n.. autoclass:: RequestCacheControl\n :members:\n :inherited-members: ImmutableDictMixin, CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ResponseCacheControl\n :members:\n :inherited-members: CallbackDict\n :member-order: groupwise\n\n.. autoclass:: ETags\n :members:\n\n.. autoclass:: Authorization\n :members:\n\n.. autoclass:: WWWAuthenticate\n :members:\n\n.. autoclass:: IfRange\n :members:\n\n.. autoclass:: Range\n :members:\n\n.. autoclass:: ContentRange\n :members:\n\n\nOthers\n======\n\n.. autoclass:: FileStorage\n :members:\n\n .. attribute:: stream\n\n The input stream for the uploaded file. This usually points to an\n open temporary file.\n\n .. attribute:: filename\n\n The filename of the file on the client. Can be a ``str``, or an\n instance of ``os.PathLike``.\n\n .. attribute:: name\n\n The name of the form field.\n\n .. attribute:: headers\n\n The multipart headers as :class:`Headers` object. This usually contains\n irrelevant information but in combination with custom multipart requests\n the raw headers might be interesting.\n\n .. versionadded:: 0.6\n""]",unanswerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/datastructures.rst#codepoints:0:3304"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:datastructures.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-index.rst-head0,dp-Werkzeug-index.rst,Werkzeug 3.1.9 documentation: Serving and Testing,"["".. rst-class:: hide-header\n\nWerkzeug\n========\n\n.. image:: _static/werkzeug-name.svg\n :align: center\n :height: 200px\n\n*werkzeug* German noun: \""tool\"".\nEtymology: *werk* (\""work\""), *zeug* (\""stuff\"")\n\nWerkzeug is a comprehensive `WSGI`_ web application library. It began as\na simple collection of various utilities for WSGI applications and has\nbecome one of the most advanced WSGI utility libraries.\n\nWerkzeug doesn't enforce any dependencies. It is up to the developer to\nchoose a template engine, database adapter, and even how to handle\nrequests.\n\n.. _WSGI: https://wsgi.readthedocs.io/en/latest/\n\n\nGetting Started\n---------------\n\n.. toctree::\n :maxdepth: 2\n\n installation\n tutorial\n levels\n quickstart\n\n\nServing and Testing\n-------------------\n\n.. toctree::\n :maxdepth: 2\n\n serving\n test\n debug\n\n\nReference\n---------\n\n.. toctree::\n :maxdepth: 2\n\n wrappers\n routing\n wsgi\n http\n datastructures\n utils\n urls\n local\n middleware/index\n exceptions\n\n\nDeployment\n----------\n\n.. toctree::\n :maxdepth: 3\n\n deployment/index\n\n\nAdditional Information\n----------------------\n\n.. toctree::\n :maxdepth: 2\n\n terms\n request_data\n license\n changes\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/index.rst#codepoints:0:1195"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:index.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-index.rst-head1,dp-Werkzeug-index.rst,Werkzeug 3.1.9 documentation: Deployment,"["".. rst-class:: hide-header\n\nWerkzeug\n========\n\n.. image:: _static/werkzeug-name.svg\n :align: center\n :height: 200px\n\n*werkzeug* German noun: \""tool\"".\nEtymology: *werk* (\""work\""), *zeug* (\""stuff\"")\n\nWerkzeug is a comprehensive `WSGI`_ web application library. It began as\na simple collection of various utilities for WSGI applications and has\nbecome one of the most advanced WSGI utility libraries.\n\nWerkzeug doesn't enforce any dependencies. It is up to the developer to\nchoose a template engine, database adapter, and even how to handle\nrequests.\n\n.. _WSGI: https://wsgi.readthedocs.io/en/latest/\n\n\nGetting Started\n---------------\n\n.. toctree::\n :maxdepth: 2\n\n installation\n tutorial\n levels\n quickstart\n\n\nServing and Testing\n-------------------\n\n.. toctree::\n :maxdepth: 2\n\n serving\n test\n debug\n\n\nReference\n---------\n\n.. toctree::\n :maxdepth: 2\n\n wrappers\n routing\n wsgi\n http\n datastructures\n utils\n urls\n local\n middleware/index\n exceptions\n\n\nDeployment\n----------\n\n.. toctree::\n :maxdepth: 3\n\n deployment/index\n\n\nAdditional Information\n----------------------\n\n.. toctree::\n :maxdepth: 2\n\n terms\n request_data\n license\n changes\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/index.rst#codepoints:0:1195"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:index.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-index.rst-head2,dp-Werkzeug-index.rst,Werkzeug 3.1.9 documentation: Getting Started,"["".. rst-class:: hide-header\n\nWerkzeug\n========\n\n.. image:: _static/werkzeug-name.svg\n :align: center\n :height: 200px\n\n*werkzeug* German noun: \""tool\"".\nEtymology: *werk* (\""work\""), *zeug* (\""stuff\"")\n\nWerkzeug is a comprehensive `WSGI`_ web application library. It began as\na simple collection of various utilities for WSGI applications and has\nbecome one of the most advanced WSGI utility libraries.\n\nWerkzeug doesn't enforce any dependencies. It is up to the developer to\nchoose a template engine, database adapter, and even how to handle\nrequests.\n\n.. _WSGI: https://wsgi.readthedocs.io/en/latest/\n\n\nGetting Started\n---------------\n\n.. toctree::\n :maxdepth: 2\n\n installation\n tutorial\n levels\n quickstart\n\n\nServing and Testing\n-------------------\n\n.. toctree::\n :maxdepth: 2\n\n serving\n test\n debug\n\n\nReference\n---------\n\n.. toctree::\n :maxdepth: 2\n\n wrappers\n routing\n wsgi\n http\n datastructures\n utils\n urls\n local\n middleware/index\n exceptions\n\n\nDeployment\n----------\n\n.. toctree::\n :maxdepth: 3\n\n deployment/index\n\n\nAdditional Information\n----------------------\n\n.. toctree::\n :maxdepth: 2\n\n terms\n request_data\n license\n changes\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/index.rst#codepoints:0:1195"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:index.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-installation.rst-head0,dp-Werkzeug-installation.rst,Werkzeug 3.1.9 documentation: Activate the environment,"[""Installation\n============\n\n\nPython Version\n--------------\n\nWe recommend using the latest version of Python. Werkzeug supports\nPython 3.9 and newer.\n\n\nOptional dependencies\n~~~~~~~~~~~~~~~~~~~~~\n\nThese distributions will not be installed automatically. Werkzeug will\ndetect and use them if you install them.\n\n* `Colorama`_ provides request log highlighting when using the\n development server on Windows. This works automatically on other\n systems.\n* `Watchdog`_ provides a faster, more efficient reloader for the\n development server.\n\n.. _Colorama: https://pypi.org/project/colorama/\n.. _Watchdog: https://pypi.org/project/watchdog/\n\n\ngreenlet\n~~~~~~~~\n\nYou may choose to use gevent or eventlet with your application. In this\ncase, greenlet>=1.0 is required. When using PyPy, PyPy>=7.3.7 is\nrequired.\n\nThese are not minimum supported versions, they only indicate the first\nversions that added necessary features. You should use the latest\nversions of each.\n\n\nVirtual environments\n--------------------\n\nUse a virtual environment to manage the dependencies for your project,\nboth in development and in production.\n\nWhat problem does a virtual environment solve? The more Python\nprojects you have, the more likely it is that you need to work with\ndifferent versions of Python libraries, or even Python itself. Newer\nversions of libraries for one project can break compatibility in\nanother project.\n\nVirtual environments are independent groups of Python libraries, one for\neach project. Packages installed for one project will not affect other\nprojects or the operating system's packages.\n\nPython comes bundled with the :mod:`venv` module to create virtual\nenvironments.\n\n\nCreate an environment\n~~~~~~~~~~~~~~~~~~~~~\n\nCreate a project folder and a :file:`venv` folder within:\n\n.. code-block:: sh\n\n mkdir myproject\n cd myproject\n python3 -m venv venv\n\nOn Windows:\n\n.. code-block:: bat\n\n py -3 -m venv venv\n\n\nActivate the environment\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nBefore you work on your project, activate the corresponding environment:\n\n.. code-block:: sh\n\n . venv/bin/activate\n\nOn Windows:\n\n.. code-block:: bat\n\n venv\\Scripts\\activate\n\nYour shell prompt will change to show the name of the activated\nenvironment.\n\n\nInstall Werkzeug\n----------------\n\nWithin the activated environment, use the following command to install\nWerkzeug:\n\n.. code-block:: sh\n\n pip install Werkzeug\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/installation.rst#codepoints:0:2389"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:installation.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-installation.rst-head1,dp-Werkzeug-installation.rst,Werkzeug 3.1.9 documentation: Installation,"[""Installation\n============\n\n\nPython Version\n--------------\n\nWe recommend using the latest version of Python. Werkzeug supports\nPython 3.9 and newer.\n\n\nOptional dependencies\n~~~~~~~~~~~~~~~~~~~~~\n\nThese distributions will not be installed automatically. Werkzeug will\ndetect and use them if you install them.\n\n* `Colorama`_ provides request log highlighting when using the\n development server on Windows. This works automatically on other\n systems.\n* `Watchdog`_ provides a faster, more efficient reloader for the\n development server.\n\n.. _Colorama: https://pypi.org/project/colorama/\n.. _Watchdog: https://pypi.org/project/watchdog/\n\n\ngreenlet\n~~~~~~~~\n\nYou may choose to use gevent or eventlet with your application. In this\ncase, greenlet>=1.0 is required. When using PyPy, PyPy>=7.3.7 is\nrequired.\n\nThese are not minimum supported versions, they only indicate the first\nversions that added necessary features. You should use the latest\nversions of each.\n\n\nVirtual environments\n--------------------\n\nUse a virtual environment to manage the dependencies for your project,\nboth in development and in production.\n\nWhat problem does a virtual environment solve? The more Python\nprojects you have, the more likely it is that you need to work with\ndifferent versions of Python libraries, or even Python itself. Newer\nversions of libraries for one project can break compatibility in\nanother project.\n\nVirtual environments are independent groups of Python libraries, one for\neach project. Packages installed for one project will not affect other\nprojects or the operating system's packages.\n\nPython comes bundled with the :mod:`venv` module to create virtual\nenvironments.\n\n\nCreate an environment\n~~~~~~~~~~~~~~~~~~~~~\n\nCreate a project folder and a :file:`venv` folder within:\n\n.. code-block:: sh\n\n mkdir myproject\n cd myproject\n python3 -m venv venv\n\nOn Windows:\n\n.. code-block:: bat\n\n py -3 -m venv venv\n\n\nActivate the environment\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nBefore you work on your project, activate the corresponding environment:\n\n.. code-block:: sh\n\n . venv/bin/activate\n\nOn Windows:\n\n.. code-block:: bat\n\n venv\\Scripts\\activate\n\nYour shell prompt will change to show the name of the activated\nenvironment.\n\n\nInstall Werkzeug\n----------------\n\nWithin the activated environment, use the following command to install\nWerkzeug:\n\n.. code-block:: sh\n\n pip install Werkzeug\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/installation.rst#codepoints:0:2389"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:installation.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-werkzeug-3.1-installation.rst-head2,dp-Werkzeug-installation.rst,Werkzeug 3.1.9 documentation: greenlet,"[""Installation\n============\n\n\nPython Version\n--------------\n\nWe recommend using the latest version of Python. Werkzeug supports\nPython 3.9 and newer.\n\n\nOptional dependencies\n~~~~~~~~~~~~~~~~~~~~~\n\nThese distributions will not be installed automatically. Werkzeug will\ndetect and use them if you install them.\n\n* `Colorama`_ provides request log highlighting when using the\n development server on Windows. This works automatically on other\n systems.\n* `Watchdog`_ provides a faster, more efficient reloader for the\n development server.\n\n.. _Colorama: https://pypi.org/project/colorama/\n.. _Watchdog: https://pypi.org/project/watchdog/\n\n\ngreenlet\n~~~~~~~~\n\nYou may choose to use gevent or eventlet with your application. In this\ncase, greenlet>=1.0 is required. When using PyPy, PyPy>=7.3.7 is\nrequired.\n\nThese are not minimum supported versions, they only indicate the first\nversions that added necessary features. You should use the latest\nversions of each.\n\n\nVirtual environments\n--------------------\n\nUse a virtual environment to manage the dependencies for your project,\nboth in development and in production.\n\nWhat problem does a virtual environment solve? The more Python\nprojects you have, the more likely it is that you need to work with\ndifferent versions of Python libraries, or even Python itself. Newer\nversions of libraries for one project can break compatibility in\nanother project.\n\nVirtual environments are independent groups of Python libraries, one for\neach project. Packages installed for one project will not affect other\nprojects or the operating system's packages.\n\nPython comes bundled with the :mod:`venv` module to create virtual\nenvironments.\n\n\nCreate an environment\n~~~~~~~~~~~~~~~~~~~~~\n\nCreate a project folder and a :file:`venv` folder within:\n\n.. code-block:: sh\n\n mkdir myproject\n cd myproject\n python3 -m venv venv\n\nOn Windows:\n\n.. code-block:: bat\n\n py -3 -m venv venv\n\n\nActivate the environment\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nBefore you work on your project, activate the corresponding environment:\n\n.. code-block:: sh\n\n . venv/bin/activate\n\nOn Windows:\n\n.. code-block:: bat\n\n venv\\Scripts\\activate\n\nYour shell prompt will change to show the name of the activated\nenvironment.\n\n\nInstall Werkzeug\n----------------\n\nWithin the activated environment, use the following command to install\nWerkzeug:\n\n.. code-block:: sh\n\n pip install Werkzeug\n""]",[],answerable,"[{""license"": ""BSD-3-Clause"", ""locator"": ""werkzeug-3.1.9/docs/installation.rst#codepoints:0:2389"", ""revision"": ""3.1.9+sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060"", ""source_id"": ""werkzeug-3.1:installation.rst"", ""uri"": ""https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym0,dp-attrs-api.rst,How is attrs.converters.pipe documented in attrs 26.1.0?,"[""Converters\n----------\n\n.. autoclass:: attrs.Converter\n\n For example:\n\n .. doctest::\n\n >>> def complicated(value, self_, field):\n ... return int(value) * self_.factor + field.metadata[\""offset\""]\n >>> @define\n ... class C:\n ... factor = 5 # not an *attrs* field\n ... x = field(\n ... metadata={\""offset\"": 200},\n ... converter=attrs.Converter(\n ... complicated,\n ... takes_self=True, takes_field=True\n ... ))\n >>> C(\""42\"")\n C(x=410)\n\n\n.. module:: attrs.converters\n\nAll objects from ``attrs.converters`` are also available from ``attr.converters`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.converters.pipe\n\n For convenience, it's also possible to pass a list to `attrs.field` / `attr.ib`'s converter arguments.\n\n Thus the following two statements are equivalent::\n\n x = attrs.field(converter=attrs.converter.pipe(c1, c2, c3))\n x = attrs.field(converter=[c1, c2, c3])\n\n.. autofunction:: attrs.converters.optional\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(converter=attrs.converters.optional(int))\n >>> C(None)\n C(x=None)\n >>> C(42)\n C(x=42)\n\n\n.. autofunction:: attrs.converters.default_if_none\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.default_if_none(\""\"")\n ... )\n >>> C(None)\n C(x='')\n\n\n.. autofunction:: attrs.converters.to_bool(val)\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.to_bool\n ... )\n >>> C(\""yes\"")\n C(x=True)\n >>> C(0)\n C(x=False)\n >>> C(\""norway\"")\n Traceback (most recent call last):\n File \""\"", line 1, in \n ValueError: Cannot convert value to bool: norway\n\n\n\n\n.. _api_setters:\n\nSetters\n-------\n\n.. module:: attrs.setters\n\nThese are helpers that you can use together with `attrs.define`'s and `attrs.field`'s ``on_setattr`` arguments.\nAll setters in ``attrs.setters`` are also available from ``attr.setters`` (it's the same module in a different namespace).\n\n.. autofunction:: frozen\n.. autofunction:: validate\n.. autofunction:: convert\n.. autofunction:: pipe\n\n.. data:: NO_OP\n\n Sentinel for disabling class-wide *on_setattr* hooks for certain attributes.\n\n Does not work in `attrs.setters.pipe` or within lists.\n\n .. versionadded:: 20.1.0\n\n For example, only ``x`` is frozen here:\n\n .. doctest::\n\n >>> @define(on_setattr=attr.setters.frozen)\n ... class C:\n ... x = field()\n ... y = field(on_setattr=attr.setters.NO_OP)\n >>> c = C(1, 2)\n >>> c.y = 3\n >>> c.y\n 3\n >>> c.x = 4\n Traceback (most recent call last):\n ...\n attrs.exceptions.FrozenAttributeError: ()\n\n .. tip::\n Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.\n""]","[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n"", ""Validators\n----------\n\n.. module:: attrs.validators\n\n*attrs* comes with some common validators in the ``attrs.validators`` module.\nAll objects from ``attrs.validators`` are also available from ``attr.validators`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.validators.lt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.lt(42))\n >>> C(41)\n C(x=41)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be < 42: 42\"")\n\n.. autofunction:: attrs.validators.le\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.le(42))\n >>> C(42)\n C(x=42)\n >>> C(43)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be <= 42: 43\"")\n\n.. autofunction:: attrs.validators.ge\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = attrs.field(validator=attrs.validators.ge(42))\n >>> C(42)\n C(x=42)\n >>> C(41)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be => 42: 41\"")\n\n.. autofunction:: attrs.validators.gt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.gt(42))\n >>> C(43)\n C(x=43)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be > 42: 42\"")\n\n.. autofunction:: attrs.validators.max_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.max_len(4))\n >>> C(\""spam\"")\n C(x='spam')\n >>> C(\""bacon\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be <= 4: 5\"")\n\n.. autofunction:: attrs.validators.min_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.min_len(1))\n >>> C(\""bacon\"")\n C(x='bacon')\n >>> C(\""\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be => 1: 0\"")\n\n.. autofunction:: attrs.validators.instance_of\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> C(42)\n C(x=42)\n >>> C(\""42\"")\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '42' that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, type=None, kw_only=False), , '42')\n >>> C(None)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got None that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, repr=True, cmp=True, hash=None, init=True, type=None, kw_only=False), , None)\n\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:21786:24870"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym1,dp-attrs-api.rst,attrs 26.1.0: what does attrs.Attribute do?,"[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n""]",[],answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:0:3754"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym2,dp-attrs-api.rst,How is attrs.evolve documented in attrs 26.1.0?,"[""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n""]","[""Validators\n----------\n\n.. module:: attrs.validators\n\n*attrs* comes with some common validators in the ``attrs.validators`` module.\nAll objects from ``attrs.validators`` are also available from ``attr.validators`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.validators.lt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.lt(42))\n >>> C(41)\n C(x=41)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be < 42: 42\"")\n\n.. autofunction:: attrs.validators.le\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.le(42))\n >>> C(42)\n C(x=42)\n >>> C(43)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be <= 42: 43\"")\n\n.. autofunction:: attrs.validators.ge\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = attrs.field(validator=attrs.validators.ge(42))\n >>> C(42)\n C(x=42)\n >>> C(41)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be => 42: 41\"")\n\n.. autofunction:: attrs.validators.gt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.gt(42))\n >>> C(43)\n C(x=43)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be > 42: 42\"")\n\n.. autofunction:: attrs.validators.max_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.max_len(4))\n >>> C(\""spam\"")\n C(x='spam')\n >>> C(\""bacon\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be <= 4: 5\"")\n\n.. autofunction:: attrs.validators.min_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.min_len(1))\n >>> C(\""bacon\"")\n C(x='bacon')\n >>> C(\""\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be => 1: 0\"")\n\n.. autofunction:: attrs.validators.instance_of\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> C(42)\n C(x=42)\n >>> C(\""42\"")\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '42' that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, type=None, kw_only=False), , '42')\n >>> C(None)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got None that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, repr=True, cmp=True, hash=None, init=True, type=None, kw_only=False), , None)\n\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n"", ""\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n .. doctest::\n\n >>> import enum\n >>> class State(enum.Enum):\n ... ON = \""on\""\n ... OFF = \""off\""\n >>> @define\n ... class C:\n ... state = field(validator=attrs.validators.in_(State))\n ... val = field(validator=attrs.validators.in_([1, 2, 3]))\n >>> C(State.ON, 1)\n C(state=, val=1)\n >>> C(\""On\"", 1)\n Traceback (most recent call last):\n ...\n ValueError: 'state' must be in (got 'On'), Attribute(name='state', default=NOTHING, validator=>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), , 'on')\n >>> C(State.ON, 4)\n Traceback (most recent call last):\n ...\n ValueError: 'val' must be in [1, 2, 3] (got 4), Attribute(name='val', default=NOTHING, validator=, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), [1, 2, 3], 4)\n\n.. autofunction:: attrs.validators.and_\n\n For convenience, it's also possible to pass a list to `attrs.field`'s validator argument.\n\n Thus the following two statements are equivalent::\n\n x = field(validator=attrs.validators.and_(v1, v2, v3))\n x = field(validator=[v1, v2, v3])\n\n.. autofunction:: attrs.validators.or_\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... val: int | list[int] = field(\n ... validator=attrs.validators.or_(\n ... attrs.validators.instance_of(int),\n ... attrs.validators.deep_iterable(attrs.validators.instance_of(int)),\n ... )\n ... )\n >>> C(42)\n C(val=42)\n >>> C([1, 2, 3])\n C(val=[1, 2, 3])\n >>> C(val='42')\n Traceback (most recent call last):\n ...\n ValueError: None of (>, >>) satisfied for value '42'\n\n.. autofunction:: attrs.validators.not_\n\n For example:\n\n .. doctest::\n\n >>> reserved_names = {\""id\"", \""time\"", \""source\""}\n >>> @define\n ... class Measurement:\n ... tags = field(\n ... validator=attrs.validators.deep_mapping(\n ... key_validator=attrs.validators.not_(\n ... attrs.validators.in_(reserved_names),\n ... msg=\""reserved tag key\"",\n ... ),\n ... value_validator=attrs.validators.instance_of((str, int)),\n ... )\n ... )\n >>> Measurement(tags={\""source\"": \""universe\""})\n Traceback (most recent call last):\n ...\n ValueError: (\""reserved tag key\"", Attribute(name='tags', default=NOTHING, validator=, capturing (, )>, type=None, kw_only=False), , {'source_': 'universe'}, (, ))\n >>> Measurement(tags={\""source_\"": \""universe\""})\n Measurement(tags={'source_': 'universe'})\n\n\n.. autofunction:: attrs.validators.optional\n\n For example:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:3754:9570"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym3,dp-attrs-api.rst,attrs 26.1.0: what does attrs.validators.and_ do?,"[""\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n .. doctest::\n\n >>> import enum\n >>> class State(enum.Enum):\n ... ON = \""on\""\n ... OFF = \""off\""\n >>> @define\n ... class C:\n ... state = field(validator=attrs.validators.in_(State))\n ... val = field(validator=attrs.validators.in_([1, 2, 3]))\n >>> C(State.ON, 1)\n C(state=, val=1)\n >>> C(\""On\"", 1)\n Traceback (most recent call last):\n ...\n ValueError: 'state' must be in (got 'On'), Attribute(name='state', default=NOTHING, validator=>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), , 'on')\n >>> C(State.ON, 4)\n Traceback (most recent call last):\n ...\n ValueError: 'val' must be in [1, 2, 3] (got 4), Attribute(name='val', default=NOTHING, validator=, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), [1, 2, 3], 4)\n\n.. autofunction:: attrs.validators.and_\n\n For convenience, it's also possible to pass a list to `attrs.field`'s validator argument.\n\n Thus the following two statements are equivalent::\n\n x = field(validator=attrs.validators.and_(v1, v2, v3))\n x = field(validator=[v1, v2, v3])\n\n.. autofunction:: attrs.validators.or_\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... val: int | list[int] = field(\n ... validator=attrs.validators.or_(\n ... attrs.validators.instance_of(int),\n ... attrs.validators.deep_iterable(attrs.validators.instance_of(int)),\n ... )\n ... )\n >>> C(42)\n C(val=42)\n >>> C([1, 2, 3])\n C(val=[1, 2, 3])\n >>> C(val='42')\n Traceback (most recent call last):\n ...\n ValueError: None of (>, >>) satisfied for value '42'\n\n.. autofunction:: attrs.validators.not_\n\n For example:\n\n .. doctest::\n\n >>> reserved_names = {\""id\"", \""time\"", \""source\""}\n >>> @define\n ... class Measurement:\n ... tags = field(\n ... validator=attrs.validators.deep_mapping(\n ... key_validator=attrs.validators.not_(\n ... attrs.validators.in_(reserved_names),\n ... msg=\""reserved tag key\"",\n ... ),\n ... value_validator=attrs.validators.instance_of((str, int)),\n ... )\n ... )\n >>> Measurement(tags={\""source\"": \""universe\""})\n Traceback (most recent call last):\n ...\n ValueError: (\""reserved tag key\"", Attribute(name='tags', default=NOTHING, validator=, capturing (, )>, type=None, kw_only=False), , {'source_': 'universe'}, (, ))\n >>> Measurement(tags={\""source_\"": \""universe\""})\n Measurement(tags={'source_': 'universe'})\n\n\n.. autofunction:: attrs.validators.optional\n\n For example:\n\n""]","[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n"", ""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:12632:16161"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym4,dp-attrs-api.rst,What is the signature of attrs.exceptions.FrozenError in attrs 26.1.0?,"[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n""]","[""Converters\n----------\n\n.. autoclass:: attrs.Converter\n\n For example:\n\n .. doctest::\n\n >>> def complicated(value, self_, field):\n ... return int(value) * self_.factor + field.metadata[\""offset\""]\n >>> @define\n ... class C:\n ... factor = 5 # not an *attrs* field\n ... x = field(\n ... metadata={\""offset\"": 200},\n ... converter=attrs.Converter(\n ... complicated,\n ... takes_self=True, takes_field=True\n ... ))\n >>> C(\""42\"")\n C(x=410)\n\n\n.. module:: attrs.converters\n\nAll objects from ``attrs.converters`` are also available from ``attr.converters`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.converters.pipe\n\n For convenience, it's also possible to pass a list to `attrs.field` / `attr.ib`'s converter arguments.\n\n Thus the following two statements are equivalent::\n\n x = attrs.field(converter=attrs.converter.pipe(c1, c2, c3))\n x = attrs.field(converter=[c1, c2, c3])\n\n.. autofunction:: attrs.converters.optional\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(converter=attrs.converters.optional(int))\n >>> C(None)\n C(x=None)\n >>> C(42)\n C(x=42)\n\n\n.. autofunction:: attrs.converters.default_if_none\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.default_if_none(\""\"")\n ... )\n >>> C(None)\n C(x='')\n\n\n.. autofunction:: attrs.converters.to_bool(val)\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.to_bool\n ... )\n >>> C(\""yes\"")\n C(x=True)\n >>> C(0)\n C(x=False)\n >>> C(\""norway\"")\n Traceback (most recent call last):\n File \""\"", line 1, in \n ValueError: Cannot convert value to bool: norway\n\n\n\n\n.. _api_setters:\n\nSetters\n-------\n\n.. module:: attrs.setters\n\nThese are helpers that you can use together with `attrs.define`'s and `attrs.field`'s ``on_setattr`` arguments.\nAll setters in ``attrs.setters`` are also available from ``attr.setters`` (it's the same module in a different namespace).\n\n.. autofunction:: frozen\n.. autofunction:: validate\n.. autofunction:: convert\n.. autofunction:: pipe\n\n.. data:: NO_OP\n\n Sentinel for disabling class-wide *on_setattr* hooks for certain attributes.\n\n Does not work in `attrs.setters.pipe` or within lists.\n\n .. versionadded:: 20.1.0\n\n For example, only ``x`` is frozen here:\n\n .. doctest::\n\n >>> @define(on_setattr=attr.setters.frozen)\n ... class C:\n ... x = field()\n ... y = field(on_setattr=attr.setters.NO_OP)\n >>> c = C(1, 2)\n >>> c.y = 3\n >>> c.y\n 3\n >>> c.x = 4\n Traceback (most recent call last):\n ...\n attrs.exceptions.FrozenAttributeError: ()\n\n .. tip::\n Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.\n"", ""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:0:3754"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-sym5,dp-attrs-api.rst,What is the signature of attrs.validators.instance_of in attrs 26.1.0?,"[""Validators\n----------\n\n.. module:: attrs.validators\n\n*attrs* comes with some common validators in the ``attrs.validators`` module.\nAll objects from ``attrs.validators`` are also available from ``attr.validators`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.validators.lt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.lt(42))\n >>> C(41)\n C(x=41)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be < 42: 42\"")\n\n.. autofunction:: attrs.validators.le\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.le(42))\n >>> C(42)\n C(x=42)\n >>> C(43)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be <= 42: 43\"")\n\n.. autofunction:: attrs.validators.ge\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = attrs.field(validator=attrs.validators.ge(42))\n >>> C(42)\n C(x=42)\n >>> C(41)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be => 42: 41\"")\n\n.. autofunction:: attrs.validators.gt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.gt(42))\n >>> C(43)\n C(x=43)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be > 42: 42\"")\n\n.. autofunction:: attrs.validators.max_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.max_len(4))\n >>> C(\""spam\"")\n C(x='spam')\n >>> C(\""bacon\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be <= 4: 5\"")\n\n.. autofunction:: attrs.validators.min_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.min_len(1))\n >>> C(\""bacon\"")\n C(x='bacon')\n >>> C(\""\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be => 1: 0\"")\n\n.. autofunction:: attrs.validators.instance_of\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> C(42)\n C(x=42)\n >>> C(\""42\"")\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '42' that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, type=None, kw_only=False), , '42')\n >>> C(None)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got None that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, repr=True, cmp=True, hash=None, init=True, type=None, kw_only=False), , None)\n\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n""]","[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n"", ""Converters\n----------\n\n.. autoclass:: attrs.Converter\n\n For example:\n\n .. doctest::\n\n >>> def complicated(value, self_, field):\n ... return int(value) * self_.factor + field.metadata[\""offset\""]\n >>> @define\n ... class C:\n ... factor = 5 # not an *attrs* field\n ... x = field(\n ... metadata={\""offset\"": 200},\n ... converter=attrs.Converter(\n ... complicated,\n ... takes_self=True, takes_field=True\n ... ))\n >>> C(\""42\"")\n C(x=410)\n\n\n.. module:: attrs.converters\n\nAll objects from ``attrs.converters`` are also available from ``attr.converters`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.converters.pipe\n\n For convenience, it's also possible to pass a list to `attrs.field` / `attr.ib`'s converter arguments.\n\n Thus the following two statements are equivalent::\n\n x = attrs.field(converter=attrs.converter.pipe(c1, c2, c3))\n x = attrs.field(converter=[c1, c2, c3])\n\n.. autofunction:: attrs.converters.optional\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(converter=attrs.converters.optional(int))\n >>> C(None)\n C(x=None)\n >>> C(42)\n C(x=42)\n\n\n.. autofunction:: attrs.converters.default_if_none\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.default_if_none(\""\"")\n ... )\n >>> C(None)\n C(x='')\n\n\n.. autofunction:: attrs.converters.to_bool(val)\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.to_bool\n ... )\n >>> C(\""yes\"")\n C(x=True)\n >>> C(0)\n C(x=False)\n >>> C(\""norway\"")\n Traceback (most recent call last):\n File \""\"", line 1, in \n ValueError: Cannot convert value to bool: norway\n\n\n\n\n.. _api_setters:\n\nSetters\n-------\n\n.. module:: attrs.setters\n\nThese are helpers that you can use together with `attrs.define`'s and `attrs.field`'s ``on_setattr`` arguments.\nAll setters in ``attrs.setters`` are also available from ``attr.setters`` (it's the same module in a different namespace).\n\n.. autofunction:: frozen\n.. autofunction:: validate\n.. autofunction:: convert\n.. autofunction:: pipe\n\n.. data:: NO_OP\n\n Sentinel for disabling class-wide *on_setattr* hooks for certain attributes.\n\n Does not work in `attrs.setters.pipe` or within lists.\n\n .. versionadded:: 20.1.0\n\n For example, only ``x`` is frozen here:\n\n .. doctest::\n\n >>> @define(on_setattr=attr.setters.frozen)\n ... class C:\n ... x = field()\n ... y = field(on_setattr=attr.setters.NO_OP)\n >>> c = C(1, 2)\n >>> c.y = 3\n >>> c.y\n 3\n >>> c.x = 4\n Traceback (most recent call last):\n ...\n attrs.exceptions.FrozenAttributeError: ()\n\n .. tip::\n Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:9570:12690"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-head0,dp-attrs-api.rst,attrs 26.1.0 documentation: Converters,"[""Converters\n----------\n\n.. autoclass:: attrs.Converter\n\n For example:\n\n .. doctest::\n\n >>> def complicated(value, self_, field):\n ... return int(value) * self_.factor + field.metadata[\""offset\""]\n >>> @define\n ... class C:\n ... factor = 5 # not an *attrs* field\n ... x = field(\n ... metadata={\""offset\"": 200},\n ... converter=attrs.Converter(\n ... complicated,\n ... takes_self=True, takes_field=True\n ... ))\n >>> C(\""42\"")\n C(x=410)\n\n\n.. module:: attrs.converters\n\nAll objects from ``attrs.converters`` are also available from ``attr.converters`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.converters.pipe\n\n For convenience, it's also possible to pass a list to `attrs.field` / `attr.ib`'s converter arguments.\n\n Thus the following two statements are equivalent::\n\n x = attrs.field(converter=attrs.converter.pipe(c1, c2, c3))\n x = attrs.field(converter=[c1, c2, c3])\n\n.. autofunction:: attrs.converters.optional\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(converter=attrs.converters.optional(int))\n >>> C(None)\n C(x=None)\n >>> C(42)\n C(x=42)\n\n\n.. autofunction:: attrs.converters.default_if_none\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.default_if_none(\""\"")\n ... )\n >>> C(None)\n C(x='')\n\n\n.. autofunction:: attrs.converters.to_bool(val)\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.to_bool\n ... )\n >>> C(\""yes\"")\n C(x=True)\n >>> C(0)\n C(x=False)\n >>> C(\""norway\"")\n Traceback (most recent call last):\n File \""\"", line 1, in \n ValueError: Cannot convert value to bool: norway\n\n\n\n\n.. _api_setters:\n\nSetters\n-------\n\n.. module:: attrs.setters\n\nThese are helpers that you can use together with `attrs.define`'s and `attrs.field`'s ``on_setattr`` arguments.\nAll setters in ``attrs.setters`` are also available from ``attr.setters`` (it's the same module in a different namespace).\n\n.. autofunction:: frozen\n.. autofunction:: validate\n.. autofunction:: convert\n.. autofunction:: pipe\n\n.. data:: NO_OP\n\n Sentinel for disabling class-wide *on_setattr* hooks for certain attributes.\n\n Does not work in `attrs.setters.pipe` or within lists.\n\n .. versionadded:: 20.1.0\n\n For example, only ``x`` is frozen here:\n\n .. doctest::\n\n >>> @define(on_setattr=attr.setters.frozen)\n ... class C:\n ... x = field()\n ... y = field(on_setattr=attr.setters.NO_OP)\n >>> c = C(1, 2)\n >>> c.y = 3\n >>> c.y\n 3\n >>> c.x = 4\n Traceback (most recent call last):\n ...\n attrs.exceptions.FrozenAttributeError: ()\n\n .. tip::\n Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.\n""]","[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n"", ""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:21786:24870"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-head1,dp-attrs-api.rst,attrs 26.1.0 documentation: Validators,"[""Validators\n----------\n\n.. module:: attrs.validators\n\n*attrs* comes with some common validators in the ``attrs.validators`` module.\nAll objects from ``attrs.validators`` are also available from ``attr.validators`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.validators.lt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.lt(42))\n >>> C(41)\n C(x=41)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be < 42: 42\"")\n\n.. autofunction:: attrs.validators.le\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.le(42))\n >>> C(42)\n C(x=42)\n >>> C(43)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be <= 42: 43\"")\n\n.. autofunction:: attrs.validators.ge\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = attrs.field(validator=attrs.validators.ge(42))\n >>> C(42)\n C(x=42)\n >>> C(41)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be => 42: 41\"")\n\n.. autofunction:: attrs.validators.gt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.gt(42))\n >>> C(43)\n C(x=43)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be > 42: 42\"")\n\n.. autofunction:: attrs.validators.max_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.max_len(4))\n >>> C(\""spam\"")\n C(x='spam')\n >>> C(\""bacon\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be <= 4: 5\"")\n\n.. autofunction:: attrs.validators.min_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.min_len(1))\n >>> C(\""bacon\"")\n C(x='bacon')\n >>> C(\""\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be => 1: 0\"")\n\n.. autofunction:: attrs.validators.instance_of\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> C(42)\n C(x=42)\n >>> C(\""42\"")\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '42' that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, type=None, kw_only=False), , '42')\n >>> C(None)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got None that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, repr=True, cmp=True, hash=None, init=True, type=None, kw_only=False), , None)\n\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n""]","[""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n"", ""\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n .. doctest::\n\n >>> import enum\n >>> class State(enum.Enum):\n ... ON = \""on\""\n ... OFF = \""off\""\n >>> @define\n ... class C:\n ... state = field(validator=attrs.validators.in_(State))\n ... val = field(validator=attrs.validators.in_([1, 2, 3]))\n >>> C(State.ON, 1)\n C(state=, val=1)\n >>> C(\""On\"", 1)\n Traceback (most recent call last):\n ...\n ValueError: 'state' must be in (got 'On'), Attribute(name='state', default=NOTHING, validator=>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), , 'on')\n >>> C(State.ON, 4)\n Traceback (most recent call last):\n ...\n ValueError: 'val' must be in [1, 2, 3] (got 4), Attribute(name='val', default=NOTHING, validator=, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None), [1, 2, 3], 4)\n\n.. autofunction:: attrs.validators.and_\n\n For convenience, it's also possible to pass a list to `attrs.field`'s validator argument.\n\n Thus the following two statements are equivalent::\n\n x = field(validator=attrs.validators.and_(v1, v2, v3))\n x = field(validator=[v1, v2, v3])\n\n.. autofunction:: attrs.validators.or_\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... val: int | list[int] = field(\n ... validator=attrs.validators.or_(\n ... attrs.validators.instance_of(int),\n ... attrs.validators.deep_iterable(attrs.validators.instance_of(int)),\n ... )\n ... )\n >>> C(42)\n C(val=42)\n >>> C([1, 2, 3])\n C(val=[1, 2, 3])\n >>> C(val='42')\n Traceback (most recent call last):\n ...\n ValueError: None of (>, >>) satisfied for value '42'\n\n.. autofunction:: attrs.validators.not_\n\n For example:\n\n .. doctest::\n\n >>> reserved_names = {\""id\"", \""time\"", \""source\""}\n >>> @define\n ... class Measurement:\n ... tags = field(\n ... validator=attrs.validators.deep_mapping(\n ... key_validator=attrs.validators.not_(\n ... attrs.validators.in_(reserved_names),\n ... msg=\""reserved tag key\"",\n ... ),\n ... value_validator=attrs.validators.instance_of((str, int)),\n ... )\n ... )\n >>> Measurement(tags={\""source\"": \""universe\""})\n Traceback (most recent call last):\n ...\n ValueError: (\""reserved tag key\"", Attribute(name='tags', default=NOTHING, validator=, capturing (, )>, type=None, kw_only=False), , {'source_': 'universe'}, (, ))\n >>> Measurement(tags={\""source_\"": \""universe\""})\n Measurement(tags={'source_': 'universe'})\n\n\n.. autofunction:: attrs.validators.optional\n\n For example:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:9570:12690"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-head2,dp-attrs-api.rst,attrs 26.1.0 documentation: API Reference,"[""API Reference\n=============\n\n.. module:: attrs\n\n*attrs* works by decorating a class using `attrs.define` or `attr.s` and then defining attributes on the class using `attrs.field`, `attr.ib`, or type annotations.\n\nWhat follows is the dry API explanation for people who understand how *attrs* works.\nIf you'd like a hands-on tutorial, have a look at `examples`.\n\nIf you're confused by the many names, please check out `names` for clarification, but the `TL;DR `_ is that as of version 21.3.0, *attrs* consists of **two** top-level package names:\n\n- The classic ``attr`` that powers the venerable `attr.s` and `attr.ib`.\n- The newer ``attrs`` that only contains most modern APIs and relies on `attrs.define` and `attrs.field` to define your classes.\n Additionally, some of the APIs that also exist in ``attr`` have nicer defaults (for example, `attrs.asdict`).\n\nThe ``attrs`` namespace is built *on top of* ``attr`` -- which will *never* go away -- and is just as stable, since it doesn't constitute a rewrite.\nTo keep repetition low and this document at a reasonable size, the ``attr`` namespace is `documented on a separate page `.\n\n\nCore\n----\n\n.. autofunction:: attrs.define\n\n.. function:: mutable(same_as_define)\n\n Same as `attrs.define`.\n\n .. versionadded:: 20.1.0\n\n.. function:: frozen(same_as_define)\n\n Behaves the same as `attrs.define` but sets *frozen=True* and *on_setattr=None*.\n\n .. versionadded:: 20.1.0\n\n.. autofunction:: field\n\n.. autoclass:: Attribute\n :members: evolve\n\n For example:\n\n .. doctest::\n\n >>> import attrs\n >>> from attrs import define, field\n\n >>> @define\n ... class C:\n ... x = field()\n >>> attrs.fields(C).x\n Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x')\n\n\n.. autofunction:: make_class\n\n This is handy if you want to programmatically create classes.\n\n For example:\n\n .. doctest::\n\n >>> C1 = attrs.make_class(\""C1\"", [\""x\"", \""y\""])\n >>> C1(1, 2)\n C1(x=1, y=2)\n >>> C2 = attrs.make_class(\""C2\"", {\n ... \""x\"": field(default=42),\n ... \""y\"": field(factory=list)\n ... })\n >>> C2()\n C2(x=42, y=[])\n\n\n.. autoclass:: Factory\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(default=attrs.Factory(list))\n ... y = field(default=attrs.Factory(\n ... lambda self: set(self.x),\n ... takes_self=True)\n ... )\n >>> C()\n C(x=[], y=set())\n >>> C([1, 2, 3])\n C(x=[1, 2, 3], y={1, 2, 3})\n\n\n.. autodata:: attrs.NOTHING\n :no-value:\n\n\nExceptions\n----------\n\n.. module:: attrs.exceptions\n\nAll exceptions are available from both ``attr.exceptions`` and ``attrs.exceptions`` and are the same thing.\nThat means that it doesn't matter from from which namespace they've been raised and/or caught:\n\n.. doctest::\n\n >>> import attrs, attr\n >>> try:\n ... raise attrs.exceptions.FrozenError()\n ... except attr.exceptions.FrozenError:\n ... print(\""this works!\"")\n this works!\n\n.. autoexception:: PythonTooOldError\n.. autoexception:: FrozenError\n.. autoexception:: FrozenInstanceError\n.. autoexception:: FrozenAttributeError\n.. autoexception:: AttrsAttributeNotFoundError\n.. autoexception:: NotAnAttrsClassError\n.. autoexception:: DefaultAlreadySetError\n.. autoexception:: NotCallableError\n.. autoexception:: UnannotatedAttributeError\n\n For example::\n\n @attr.s(auto_attribs=True)\n class C:\n x: int\n y = attr.ib() # <- ERROR!\n\n\n.. _helpers:\n\n""]","[""Helpers\n-------\n\n*attrs* comes with a bunch of helper methods that make working with it easier:\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.cmp_using\n\n.. autofunction:: attrs.fields\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.fields(C)\n (Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y'))\n >>> attrs.fields(C(1, 2)) is attrs.fields(C)\n True\n >>> attrs.fields(C)[1]\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields(C).y is attrs.fields(C)[1]\n True\n\n.. autofunction:: attrs.fields_dict\n\n For example:\n\n .. doctest::\n\n >>> @attr.s\n ... class C:\n ... x = attr.ib()\n ... y = attr.ib()\n >>> attrs.fields_dict(C)\n {'x': Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='x'), 'y': Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')}\n >>> attr.fields_dict(C)['y']\n Attribute(name='y', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='y')\n >>> attrs.fields_dict(C)['y'] is attrs.fields(C).y\n True\n\n.. autofunction:: attrs.has\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... pass\n >>> attrs.has(C)\n True\n >>> attrs.has(object)\n False\n\n.. autofunction:: attrs.inspect\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class CInspect:\n ... pass\n >>> attrs.inspect(CInspect) # doctest: +ELLIPSIS\n ClassProps(is_exception=False, is_slotted=True, has_weakref_slot=True, is_frozen=False, kw_only=, collected_fields_by_mro=True, added_init=True, added_repr=True, added_eq=True, added_ordering=False, hashability=, added_match_args=True, added_str=False, added_pickling=True, on_setattr_hook=.wrapped_pipe at ...>, field_transformer=None)\n\n.. autoclass:: attrs.ClassProps\n.. autoclass:: attrs.ClassProps.Hashability\n :members: HASHABLE, HASHABLE_CACHED, UNHASHABLE, LEAVE_ALONE\n.. autoclass:: attrs.ClassProps.KeywordOnly\n :members: NO, YES, FORCE\n\n.. autofunction:: attrs.resolve_types\n\n For example:\n\n .. doctest::\n\n >>> import typing\n >>> @define\n ... class A:\n ... a: typing.List['A']\n ... b: 'B'\n ...\n >>> @define\n ... class B:\n ... a: A\n ...\n >>> attrs.fields(A).a.type\n typing.List[ForwardRef('A')]\n >>> attrs.fields(A).b.type\n 'B'\n >>> attrs.resolve_types(A, globals(), locals())\n \n >>> attrs.fields(A).a.type\n typing.List[A]\n >>> attrs.fields(A).b.type\n \n\n.. autofunction:: attrs.asdict\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> attrs.asdict(C(1, C(2, 3)))\n {'x': 1, 'y': {'x': 2, 'y': 3}}\n\n.. autofunction:: attrs.astuple\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field()\n ... y = field()\n >>> attrs.astuple(C(1,2))\n (1, 2)\n\n.. module:: attrs.filters\n\n*attrs* includes helpers for filtering the attributes in `attrs.asdict` and `attrs.astuple`:\n\n.. autofunction:: include\n\n.. autofunction:: exclude\n\nSee :func:`attrs.asdict` for examples.\n\nAll objects from ``attrs.filters`` are also available from ``attr.filters`` (it's the same module in a different namespace).\n\n----\n\n.. currentmodule:: attrs\n\n.. autofunction:: attrs.evolve\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x: int\n ... y: int\n >>> i1 = C(1, 2)\n >>> i1\n C(x=1, y=2)\n >>> i2 = attrs.evolve(i1, y=3)\n >>> i2\n C(x=1, y=3)\n >>> i1 == i2\n False\n\n ``evolve`` creates a new instance using ``__init__``.\n This fact has several implications:\n\n * private attributes should be specified without the leading underscore, just like in ``__init__``.\n * attributes with ``init=False`` can't be set with ``evolve``.\n * the usual ``__init__`` validators will validate the new values.\n\n.. autofunction:: attrs.validate\n\n For example:\n\n .. doctest::\n\n >>> @define(on_setattr=attrs.setters.NO_OP)\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> i = C(1)\n >>> i.x = \""1\""\n >>> attrs.validate(i)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '1' that is a ).\"", ...)\n\n\n.. _api-validators:\n\n"", ""Validators\n----------\n\n.. module:: attrs.validators\n\n*attrs* comes with some common validators in the ``attrs.validators`` module.\nAll objects from ``attrs.validators`` are also available from ``attr.validators`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.validators.lt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.lt(42))\n >>> C(41)\n C(x=41)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be < 42: 42\"")\n\n.. autofunction:: attrs.validators.le\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.le(42))\n >>> C(42)\n C(x=42)\n >>> C(43)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be <= 42: 43\"")\n\n.. autofunction:: attrs.validators.ge\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = attrs.field(validator=attrs.validators.ge(42))\n >>> C(42)\n C(x=42)\n >>> C(41)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be => 42: 41\"")\n\n.. autofunction:: attrs.validators.gt\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.gt(42))\n >>> C(43)\n C(x=43)\n >>> C(42)\n Traceback (most recent call last):\n ...\n ValueError: (\""'x' must be > 42: 42\"")\n\n.. autofunction:: attrs.validators.max_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.max_len(4))\n >>> C(\""spam\"")\n C(x='spam')\n >>> C(\""bacon\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be <= 4: 5\"")\n\n.. autofunction:: attrs.validators.min_len\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.min_len(1))\n >>> C(\""bacon\"")\n C(x='bacon')\n >>> C(\""\"")\n Traceback (most recent call last):\n ...\n ValueError: (\""Length of 'x' must be => 1: 0\"")\n\n.. autofunction:: attrs.validators.instance_of\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(validator=attrs.validators.instance_of(int))\n >>> C(42)\n C(x=42)\n >>> C(\""42\"")\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got '42' that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, type=None, kw_only=False), , '42')\n >>> C(None)\n Traceback (most recent call last):\n ...\n TypeError: (\""'x' must be (got None that is a ).\"", Attribute(name='x', default=NOTHING, validator=>, repr=True, cmp=True, hash=None, init=True, type=None, kw_only=False), , None)\n\n.. autofunction:: attrs.validators.in_\n\n For example:\n\n""]",answerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:0:3754"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-api.rst-none0,dp-attrs-api.rst,What is the signature of attrs.converters.pipe_strict in attrs 26.1.0?,[],"[""Converters\n----------\n\n.. autoclass:: attrs.Converter\n\n For example:\n\n .. doctest::\n\n >>> def complicated(value, self_, field):\n ... return int(value) * self_.factor + field.metadata[\""offset\""]\n >>> @define\n ... class C:\n ... factor = 5 # not an *attrs* field\n ... x = field(\n ... metadata={\""offset\"": 200},\n ... converter=attrs.Converter(\n ... complicated,\n ... takes_self=True, takes_field=True\n ... ))\n >>> C(\""42\"")\n C(x=410)\n\n\n.. module:: attrs.converters\n\nAll objects from ``attrs.converters`` are also available from ``attr.converters`` (it's the same module in a different namespace).\n\n.. autofunction:: attrs.converters.pipe\n\n For convenience, it's also possible to pass a list to `attrs.field` / `attr.ib`'s converter arguments.\n\n Thus the following two statements are equivalent::\n\n x = attrs.field(converter=attrs.converter.pipe(c1, c2, c3))\n x = attrs.field(converter=[c1, c2, c3])\n\n.. autofunction:: attrs.converters.optional\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(converter=attrs.converters.optional(int))\n >>> C(None)\n C(x=None)\n >>> C(42)\n C(x=42)\n\n\n.. autofunction:: attrs.converters.default_if_none\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.default_if_none(\""\"")\n ... )\n >>> C(None)\n C(x='')\n\n\n.. autofunction:: attrs.converters.to_bool(val)\n\n For example:\n\n .. doctest::\n\n >>> @define\n ... class C:\n ... x = field(\n ... converter=attrs.converters.to_bool\n ... )\n >>> C(\""yes\"")\n C(x=True)\n >>> C(0)\n C(x=False)\n >>> C(\""norway\"")\n Traceback (most recent call last):\n File \""\"", line 1, in \n ValueError: Cannot convert value to bool: norway\n\n\n\n\n.. _api_setters:\n\nSetters\n-------\n\n.. module:: attrs.setters\n\nThese are helpers that you can use together with `attrs.define`'s and `attrs.field`'s ``on_setattr`` arguments.\nAll setters in ``attrs.setters`` are also available from ``attr.setters`` (it's the same module in a different namespace).\n\n.. autofunction:: frozen\n.. autofunction:: validate\n.. autofunction:: convert\n.. autofunction:: pipe\n\n.. data:: NO_OP\n\n Sentinel for disabling class-wide *on_setattr* hooks for certain attributes.\n\n Does not work in `attrs.setters.pipe` or within lists.\n\n .. versionadded:: 20.1.0\n\n For example, only ``x`` is frozen here:\n\n .. doctest::\n\n >>> @define(on_setattr=attr.setters.frozen)\n ... class C:\n ... x = field()\n ... y = field(on_setattr=attr.setters.NO_OP)\n >>> c = C(1, 2)\n >>> c.y = 3\n >>> c.y\n 3\n >>> c.x = 4\n Traceback (most recent call last):\n ...\n attrs.exceptions.FrozenAttributeError: ()\n\n .. tip::\n Use `attrs.define`'s *frozen* argument (or `attrs.frozen`) to freeze whole classes; it is more efficient.\n""]",unanswerable,"[{""license"": ""MIT"", ""locator"": ""attrs-26.1.0/docs/api.rst#codepoints:21786:24870"", ""revision"": ""26.1.0+sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"", ""source_id"": ""attrs-26.1:api.rst"", ""uri"": ""https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz""}]" dp-rt-attrs-26.1-index.md-head0,dp-attrs-index.md,attrs 26.1.0 documentation: This is mainly called from RTD's pre_build job!,"[""# *attrs*: Classes Without Boilerplate\n\nRelease **{sub-ref}`release`** ([What's new?](changelog.md))\n\n```{include} ../README.md\n:start-after: 'teaser-begin -->'\n:end-before: '\n\n\n\n\n\n\n\n\n\n```{include} ../README.md\n:start-after: 'sponsor-break-end -->'\n:end-before: ''\n:end-before: '\n\n\n\n\n\n\n\n\n\n```{include} ../README.md\n:start-after: 'sponsor-break-end -->'\n:end-before: ''\n:end-before: '\n\n\n\n\n\n\n\n\n\n```{include} ../README.md\n:start-after: 'sponsor-break-end -->'\n:end-before: '