pcio


Namepcio JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryProgramming contest input/output module
upload_time2024-02-12 16:50:58
maintainer
docs_urlNone
authorAndrey Demidov
requires_python>=3.12
licenseMIT License Copyright (c) 2024 Andrey Demidov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords input print contest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PCIO

Input from stdin by format. Values can distrubuted on different lines.

``` python
import pcio

# Input two integer numbers as tuple
a,b=pcio.input('ii')

# Input a list of integer numbers
arr=pcio.input(100,'i')

# Input a list of pair float numbers
arr=pcio.input(100,'ff')

# Input one symbol
pcio.input(1)

# Input one line by default
s=pcio.input()
```
Function raises EOFError on end of file and ValueError if value is not a number.

Input Format|Description
--|--
i | Integer number, skip spaces before number
f | Float number, skip spaces before number
w | Word, skip spaces before word
c | One character as string
l | One line as a string
L | One line with new line as a string
a | All input as one string


Also specialized variants

``` python
import pcio

a=pcio.input_int()
b=pcio.input_float()
c=pcio.input_char()
d=pcio.input_word()
e=pcio.input_line()
```

Print according to the format specified by the first argument.

``` python
import pcio

# Print by format
pcio.print("Hello, {}!\n", "world")

# Print a list separated by space and new line
arr=[1,2,3,10,12.2,'a']
pcio.println(arr)
# 1 2 3 10 12.2 a
pcio.println('{:02i}',arr) 
# 01 02 03 10 12 a
pcio.println('{!r}',arr)
# [1,2,3,10,12.2,'a']
```

If the first argument is not a string then the format ``'{} {} {}'`` is used where the number of parentheses is equal to the number of arguments.

Format contain "replacement fields" surrounded by curly braces ``{}``.
Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. 
If you need to include a brace character in the literal text, it can be escaped by doubling: ``{{`` and ``}}``.

```
replacement_field ::=  "{" [arg_index] [format_spec] "}"
format_spec ::=  "!" "r" | ":" [align][sign]["0"][width]["." precision][type]
align  ::=  "<" | ">" | "^"
sign            ::=  "+" | "-"
width           ::=  digit+
precision       ::=  digit+
type            ::=  "i" | "d" | "o" | "x" | "X" | "e" | "E" | "f" | "F" | "g" | "G" | "s"
```

``"!r"`` calls repr() to print.

The meaning of the various *alignment* options is as follows:

Option|Meaning
--|--
'<' | Forces the field to be left-aligned within the available space (this is the default for most objects).
'>'|Forces the field to be right-aligned within the available space (this is the default for numbers).
'^'|Forces the field to be centered within the available space.


The *sign* option is only valid for number types, and can be one of the following:

Option|Meaning
--|--
'+'| indicates that a sign should be used for both positive as well as negative numbers.
'-'| indicates that a sign should be used only for negative numbers (this is the default behavior).

*width* is a decimal integer defining the minimum total field width, including any prefixes, separators, and other formatting characters. If not specified, then the field width will be determined by the content.
Preceding the width field by a zero ('0') character enables zero-padding for numeric types.

The *precision* is a decimal integer indicating how many digits should be displayed after the 
decimal point for presentation types 'f' and 'F', or before and after the decimal point 
for presentation types 'g' or 'G'. 
For string presentation types the field indicates the maximum field size - in other words, how many
characters will be used from the field content. The precision is ignored for integer presentation types.

The available *types* are:

Type|Meaning
--|--
's'| String format. Numbers is converted to the string ('g' or 'd') and precision is ignored.
'd', 'i' | Decimal Integer. Outputs the number in base 10. String the 's' format is used instead.
'o' | Octal format. Outputs the number in base 8. For float numbers and string the 'g' and 's' format is used instead.
'x', 'X' | Hex format. Outputs the number in base 16. 
'f', 'F' | Fixed-point notation. For strings the 's' format is used and precision is ignored.
'e', 'E' | Scientific notation.
'g', 'G' | General format.

Select input/output encoding (``'utf-8'``, ``'cp1251'`` or ``'cp866'``).

``` python
# Select encoding 
pcio.encoding('cp1251')
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pcio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": "",
    "keywords": "input,print,contest",
    "author": "Andrey Demidov",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/80/20/90cd6791a148635c12cac9efc87c1577aa0aa30797044c011ceac43dfd0d/pcio-1.1.0.tar.gz",
    "platform": null,
    "description": "# PCIO\r\n\r\nInput from stdin by format. Values can distrubuted on different lines.\r\n\r\n``` python\r\nimport pcio\r\n\r\n# Input two integer numbers as tuple\r\na,b=pcio.input('ii')\r\n\r\n# Input a list of integer numbers\r\narr=pcio.input(100,'i')\r\n\r\n# Input a list of pair float numbers\r\narr=pcio.input(100,'ff')\r\n\r\n# Input one symbol\r\npcio.input(1)\r\n\r\n# Input one line by default\r\ns=pcio.input()\r\n```\r\nFunction raises EOFError on end of file and ValueError if value is not a number.\r\n\r\nInput Format|Description\r\n--|--\r\ni | Integer number, skip spaces before number\r\nf | Float number, skip spaces before number\r\nw | Word, skip spaces before word\r\nc | One character as string\r\nl | One line as a string\r\nL | One line with new line as a string\r\na | All input as one string\r\n\r\n\r\nAlso specialized variants\r\n\r\n``` python\r\nimport pcio\r\n\r\na=pcio.input_int()\r\nb=pcio.input_float()\r\nc=pcio.input_char()\r\nd=pcio.input_word()\r\ne=pcio.input_line()\r\n```\r\n\r\nPrint according to the format specified by the first argument.\r\n\r\n``` python\r\nimport pcio\r\n\r\n# Print by format\r\npcio.print(\"Hello, {}!\\n\", \"world\")\r\n\r\n# Print a list separated by space and new line\r\narr=[1,2,3,10,12.2,'a']\r\npcio.println(arr)\r\n# 1 2 3 10 12.2 a\r\npcio.println('{:02i}',arr) \r\n# 01 02 03 10 12 a\r\npcio.println('{!r}',arr)\r\n# [1,2,3,10,12.2,'a']\r\n```\r\n\r\nIf the first argument is not a string then the format ``'{} {} {}'`` is used where the number of parentheses is equal to the number of arguments.\r\n\r\nFormat contain \"replacement fields\" surrounded by curly braces ``{}``.\r\nAnything that is not contained in braces is considered literal text, which is copied unchanged to the output. \r\nIf you need to include a brace character in the literal text, it can be escaped by doubling: ``{{`` and ``}}``.\r\n\r\n```\r\nreplacement_field ::=  \"{\" [arg_index] [format_spec] \"}\"\r\nformat_spec ::=  \"!\" \"r\" | \":\" [align][sign][\"0\"][width][\".\" precision][type]\r\nalign  ::=  \"<\" | \">\" | \"^\"\r\nsign            ::=  \"+\" | \"-\"\r\nwidth           ::=  digit+\r\nprecision       ::=  digit+\r\ntype            ::=  \"i\" | \"d\" | \"o\" | \"x\" | \"X\" | \"e\" | \"E\" | \"f\" | \"F\" | \"g\" | \"G\" | \"s\"\r\n```\r\n\r\n``\"!r\"`` calls repr() to print.\r\n\r\nThe meaning of the various *alignment* options is as follows:\r\n\r\nOption|Meaning\r\n--|--\r\n'<' | Forces the field to be left-aligned within the available space (this is the default for most objects).\r\n'>'|Forces the field to be right-aligned within the available space (this is the default for numbers).\r\n'^'|Forces the field to be centered within the available space.\r\n\r\n\r\nThe *sign* option is only valid for number types, and can be one of the following:\r\n\r\nOption|Meaning\r\n--|--\r\n'+'| indicates that a sign should be used for both positive as well as negative numbers.\r\n'-'| indicates that a sign should be used only for negative numbers (this is the default behavior).\r\n\r\n*width* is a decimal integer defining the minimum total field width, including any prefixes, separators, and other formatting characters. If not specified, then the field width will be determined by the content.\r\nPreceding the width field by a zero ('0') character enables zero-padding for numeric types.\r\n\r\nThe *precision* is a decimal integer indicating how many digits should be displayed after the \r\ndecimal point for presentation types 'f' and 'F', or before and after the decimal point \r\nfor presentation types 'g' or 'G'. \r\nFor string presentation types the field indicates the maximum field size - in other words, how many\r\ncharacters will be used from the field content. The precision is ignored for integer presentation types.\r\n\r\nThe available *types* are:\r\n\r\nType|Meaning\r\n--|--\r\n's'| String format. Numbers is converted to the string ('g' or 'd') and precision is ignored.\r\n'd', 'i' | Decimal Integer. Outputs the number in base 10. String the 's' format is used instead.\r\n'o' | Octal format. Outputs the number in base 8. For float numbers and string the 'g' and 's' format is used instead.\r\n'x', 'X' | Hex format. Outputs the number in base 16. \r\n'f', 'F' | Fixed-point notation. For strings the 's' format is used and precision is ignored.\r\n'e', 'E' | Scientific notation.\r\n'g', 'G' | General format.\r\n\r\nSelect input/output encoding (``'utf-8'``, ``'cp1251'`` or ``'cp866'``).\r\n\r\n``` python\r\n# Select encoding \r\npcio.encoding('cp1251')\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Andrey Demidov  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Programming contest input/output module",
    "version": "1.1.0",
    "project_urls": null,
    "split_keywords": [
        "input",
        "print",
        "contest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a1e0fe2420b8fe6343abcf90819f716a1ab4176e2ac3520a93ec7c1fdad345a",
                "md5": "22dc7d4624c3fe49592e4b7f58983ad0",
                "sha256": "1001ada6d2ed678cfe856c0fced8797e8e539398bad31dac2deabfacd7faf16e"
            },
            "downloads": -1,
            "filename": "pcio-1.1.0-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "22dc7d4624c3fe49592e4b7f58983ad0",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.12",
            "size": 16246,
            "upload_time": "2024-02-12T16:50:57",
            "upload_time_iso_8601": "2024-02-12T16:50:57.088664Z",
            "url": "https://files.pythonhosted.org/packages/1a/1e/0fe2420b8fe6343abcf90819f716a1ab4176e2ac3520a93ec7c1fdad345a/pcio-1.1.0-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "802090cd6791a148635c12cac9efc87c1577aa0aa30797044c011ceac43dfd0d",
                "md5": "e4da944d2f2c0d6119d0f484c1ec539c",
                "sha256": "55365b062116ddc00d97ece1f52dc9b9b736d996868d5a5a382e6b99962657dc"
            },
            "downloads": -1,
            "filename": "pcio-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e4da944d2f2c0d6119d0f484c1ec539c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 11372,
            "upload_time": "2024-02-12T16:50:58",
            "upload_time_iso_8601": "2024-02-12T16:50:58.274604Z",
            "url": "https://files.pythonhosted.org/packages/80/20/90cd6791a148635c12cac9efc87c1577aa0aa30797044c011ceac43dfd0d/pcio-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-12 16:50:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pcio"
}
        
Elapsed time: 0.45727s