Skip to main content

Inputão

Um input melhor para ajudar os iniciantes em Python.

Introdução

Quando o pessoal começa a programar em Python, muitos exercícios dependem da função builtin input.

O problema é que o input do Python sempre retorna uma string e o iniciante acaba despendendo muita energia para validar os dados e pedir que o usuário digite novamente em caso de erro.

Como usar

Instale com:

pip install inputao

Use no seu código:

from inputao import input

Como funciona?

Importe o a função input.

>>> from inputao import input

Por padrão input sempre retorna string.

>>> nome = input('Qual o seu nome?')
>>> type(nome)
str

Para converter a entrada, informe a class como 2º parametro.

>>> idade = input('Qual sua idade?', int)
>>> type(idade)
int

Ou, por exemplo, crie a uma função que valide o que voce quiser.

>>> def SN(text):
>>>     if text in 'Ss':
>>>         valor = True
>>>     elif text in 'Nn':
>>>         valor = False
>>>     else:
>>>         raise ValueError('Digite S ou N.')
>>>     return valor

>>> continua = input('Deseja continuar? [Sn]', SN)
>>> type(continua)
bool

Licença

MIT

Autores

Rapaziada da Live.

Metadata

Release files for inputao 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inputao 1.2
File Size Uploaded Provenance
inputao-1.2.tar.gz 3.3 kB Without provenance Details

Release files / inputao-1.2.tar.gz

Download URL inputao-1.2.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
41d43c6752be6d17ddfc4c7c2fe8331d779a1d82d0c92b1acccb6ac2067e1b1a
BLAKE2b-256 checksum
How to use checksums
14db531f547b403e3b1ce26e76540f0d48294250c59cf2ef5c7c2e3e4a24c35c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Security for inputao 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page