Skip to content

Reading input using pycharm IDE #301

@eaudet

Description

@eaudet

When running demo.py on macos, we get this error:

termios.error: (25, 'Inappropriate ioctl for device')

Hence I propose to use the following util function instead of
readchar.readkey()

def safe_readkey():
    if not sys.stdin.isatty():
        print("WARNING: stdin is not a TTY. Falling back to input().")
        return input("Enter a key (then press Enter): ")[0]
    try:
        return readchar.readkey()
    except Exception as e:
        print(f"readkey() failed: {e}")
        return input("Enter a key (then press Enter): ")[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions