Skip to main content

Easier input for Python

Project description

Autoinput

This library is for easier input in Python. It is 100% that you don't want to do this:

while 1:
  try:
    x = int(input())
    break
  except:
    print("Please input a number")

because it is 6 lines when you can have 1 line:

x = autoinput("", autoinput_type.INTEGER)

and everything is inside the function. No work by hands.

how to use

Here is the definition

def autoinput(outstring: str,
              typeel,
              pipe_in: Callable[[str], str]=input,
              pipe_out: Callable[[str], None]=print,
              pipe_out_end_name: str="end",
              pipe_out_flush_name: str = "flush",
              use_input_argument_for_output: bool=True,
              parser=None) -> Any:

First argument - outstring, string to show.

Second argument - typeel, use autoinput_type enum to form this (example: autoinput_type.INTEGER | autoinput_type.ARRAY)

kwargs:

pipe_in - for custom input function (for example if you use GUI)

pipe_out - for custom output function

parser - for custom parser (don't use with autoinput_type except of autoinput_type.ARRAY and/or autoinput_type.STRING)

pipe_out_end_name - if your custom output function doesn't have parameter like print's end use None, if has but called not end use the parameter to specify the name.

pipe_out_flush_name - the same as pipe_out_end_name but for flush.

use_input_argument_for_output - specifies if your pipe_in should get outsring as an output.

autoinput_type - the way to specify type of data

values

autoinput_type - IntFlag used to specify the type. Here are variants of it:

autoinput_type.INTEGER - return integer

autoinput_type.FLOAT - return floating point number

autoinput_type.STRING - return string, default type

autoinput_type.BOOLYN - asks yes or no, return bool

autoinput_type.BOOLTF - asks true or false, return bool

autoinput_type.ARRAY - asks for array where values are separated by space, return array of another type (if not specified returns str)

how to use

To combine autoinput_type use |. Example:

autoinput_type.INTEGER | autoinput_type.ARRAY

WARNING: Do not combine types like that:

autoinput_type.INTEGER | autoinput_type.FLOAT

You will get an error if you try to run this.

If you need not a basic type use parser named argument.

how to get Autoinput

To get Autoinput you can run this:

pip install autoinput

or:

Linux:

python3 -m pip install autoinput

Windows:

py -m pip install autoinput

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoinput-1.5.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoinput-1.5.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file autoinput-1.5.2.tar.gz.

File metadata

  • Download URL: autoinput-1.5.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autoinput-1.5.2.tar.gz
Algorithm Hash digest
SHA256 ab5255152e46e3b3d6a2eaa0bffd8ee520135e5aa386fc2c54c31f54f543e0c8
MD5 e3e66fdf70a567fc4e4a68132005ca25
BLAKE2b-256 0bddca9a9e54ba5451986c444ea34b0b211f941b8ddf5c7f797b1ebc54138610

See more details on using hashes here.

File details

Details for the file autoinput-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: autoinput-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autoinput-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e01b06d1a6f5a0cfe4dbac455b758efb682bbdc8fe19a953b6fca7a602e3067f
MD5 1eb063ce2dccfd9bd5ee1826081e5702
BLAKE2b-256 889adda36924ac50d15cd57b69d7ba3afc22828d77ba5a402dcca34e832bfbc0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page