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.tar.gz (4.1 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-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: upgradedinput-0.0.8.tar.gz
  • Upload date:
  • Size: 4.1 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.tar.gz
Algorithm Hash digest
SHA256 8ceab7e87334cadafc7f9d052076c8292f288364b0ffac7109820137c48adb3d
MD5 35afa85df3ebc397912afd18719c93ba
BLAKE2b-256 a11f7c5da6d5874089fce75fe85406370dcb8a35f37a756d94ddaad07dd4a989

See more details on using hashes here.

File details

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

File metadata

  • Download URL: upgradedinput-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for upgradedinput-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a993843a6a4385ca00821a189bd234d5099c8358fff0999ccd302e00544e59
MD5 2dcda2bf320a1eb84aebefccb585ba1f
BLAKE2b-256 ec43d9c40d82160194488f1091890ca0b8b5c59a593ae8811abf26c0d6de2511

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