Skip to content

Characters getting from terminal using getchar returns bytes #1088

@lewoudar

Description

@lewoudar

Hello,
it is said in the documentation that getchar function always returns unicode there, but when i tried to use the code snippet of the documentation on my windows 10 machine, i always fell on "invalid input :("

I inspected the type of value returned and I realized that it was bytes. So either you have to change the documentation and the code like this:

    click.echo('Continue? [yn] ', nl=False)
    c = click.getchar()
    if c == b'y':
        click.echo('We will go on')
    elif c == b'n':
        click.echo('Abort!')
    else:
        click.echo('Invalid input :(')

either the problem have to be solved..

I'm using click 6.7, python 3.6 and I'm working under windows 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions