Skip to main content

A better input() for python

Project description

UpgradedInput

A better, minimal input() wrapper for python

Features compared to python's default input()

  • Supports hooks for functions (Before and after input, on exception and on runtime error)
  • Supports automatic conversion with validation

How to use

Install the module

pip install UpgradedInput

Use the module Example:

from UpgradedInput import UpgradedInput, InputTypes
# initialize
inp = UpgradedInput()

# Example of hooks (All of them can be left at the dafult state (None))
def before():
    print("Before!")

def after():
    print("After!")

def exception():
    print("Exception!")

def runtime_error():
    print("Runtime error!")

def invalid_user_input(text):
    print(text)
    return None

# Initialize the hooks
inp.before_input_function = before
inp.after_input_function = after
inp.end_of_file_input_function = exception
inp.runtime_error_function = runtime_error # say we lost sys.stdin or something else that triggers a runtime error
inp.invalid_user_input_function = invalid_user_input

print(inp.input()) # final call to the wrapper
print(inp.input(prompt="insert text: ")) # supports prompt (from input)

# in case the automatic conversion fails, in this example it calls invalid_user_input 
# which prints what the user typed, and returns None in this example (REFER TO DOCUMENTATION!!!!!!!!)
print(inp.input(type=InputTypes.INTEGER)) # supports automatic conversion!
print(inp.input(type=InputTypes.FLOAT)) # floats
print(inp.input(type=InputTypes.BOOL)) # booleans

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

upgradedinput-0.0.8.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

upgradedinput-0.0.8.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file upgradedinput-0.0.8.1.tar.gz.

File metadata

  • Download URL: upgradedinput-0.0.8.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for upgradedinput-0.0.8.1.tar.gz
Algorithm Hash digest
SHA256 105ba825afe89e1ee15cf9e630949188ecc4687c6a9868ab0eb28b5146c9837f
MD5 7e7f927905c870856945e44e9f623a79
BLAKE2b-256 4eadc7bc71106780bec9dafad5748a76537a9be55cf0962a0d502650ab6107a8

See more details on using hashes here.

File details

Details for the file upgradedinput-0.0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for upgradedinput-0.0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 020f8bd00ba98e22625a7e33cd2bbd468edaaf2657c354d68a8c7a75b1e83d86
MD5 e916f43e7a639814c72bcb22937ed651
BLAKE2b-256 1a3029a6de9cda2dbfb2f3c0a74100b2823984d041677dd93824a3d5bdc70830

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