Skip to content

dokelung/tinp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinp

Build Status Coverage Status

Builtin function input does not support scan formatted. Also, its return value can only be string. Users should do extra parsing actions and type conversions to get what they want.

This module provides several wrappers of builtin input. They can statisfy above requirements easily.

Requirements

Python3.3 or later.

Installation

$ pip install tinp

or you can clone this repo directly.

$ git clone https://github.com/dokelung/tinp.git

Examples

finput

Read input by format string:

>>> from tinp import finput
>>> finput(prompt='==> ', fstr='%d, %f, %s')
==> 88, 12.3, hello
(88, 12.3, 'hello')

tinput

Read input and split it into several values with specified type:

>>> from tinp import tinput
>>> tinput(prompt='please enter 5 integers: ', typ=int)
please enter 5 integers: 1 2 3 4 5
(1, 2, 3, 4, 5)

einput

Read input and evaluate it:

>>> from tinp import einput
>>> einput(prompt='==> ', typ=float)
==> 2+2
4.0

About

Library of input functions with type conversion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages