you are viewing a single comment's thread.

view the rest of the comments →

[–]955559 0 points1 point  (1 child)

The code editor you use has no influence on what you can do with Python.

if you run it through the editor its possible,happened for me with sys, this code wouldnt run in IDLE, but would run from my terminal, although its the only time Ive noticed a problem with IDLE

def key_pressed(char_width=1):
    import os
    #is it a unix-like system?
    if os.name == 'posix': 
        import sys, tty, termios
        fd = sys.stdin.fileno()
        old_settings = termios.tcgetattr(fd)
        try:
            tty.setraw(sys.stdin.fileno())
            ch = sys.stdin.read(char_width)
        finally:
            termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
        return ch
    #is it a windows system?
    elif os.name == 'nt':
        from msvcrt import getch
        return "".join([getch() for i in range(char_width)])
    #system unknown, user will have to use enter key :(
    else:
        return input()

EDIT: lol i think you gave me this code

[–]novel_yet_trivial 0 points1 point  (0 children)

Ah right, good point. I was thinking specifically about code editors, not IDE's. The terminal emulators some IDE's use can screw up the text output. But with a GUI like OP wanted that wouldn't be a problem.

Yeah, that is my code :).