Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess you will need to get a key pressed by the user.</p> <p>You can achieve it (without pressing enter) with a method like this:</p> <pre class="lang-py prettyprint-override"><code>import termios, os, sys def getkey(): fd = sys.stdin.fileno() old = termios.tcgetattr(fd) new = termios.tcgetattr(fd) new[3] = new[3] &amp; ~termios.ICANON &amp; ~termios.ECHO new[6][termios.VMIN] = 1 new[6][termios.VTIME] = 0 termios.tcsetattr(fd, termios.TCSANOW, new) c = None try: c = os.read(fd, 1) finally: termios.tcsetattr(fd, termios.TCSAFLUSH, old) return c </code></pre> <p>Then, if this key is a tab key (for example, that's something you need to implement), then display all possibilities to user. If that's any other key, print it on stdout.</p> <p>Oh, of course you will need to have getkey() looped in a while, as long as the user hits enter. You can also get a method like raw_input, that will get the whole word sign by sign, or display all the possibilities, when you hit a tab.</p> <p>At least that's the item, you can start with. If you achieve any other problems, than write about them.</p> <p>EDIT 1:</p> <p>The get_word method can look like this:</p> <pre class="lang-py prettyprint-override"><code>def get_word(): s = "" while True: a = getkey() if a == "\n": break elif a == "\t": print "all possibilities" else: s += a return s word = get_word() print word </code></pre> <p>The issue I'm occuring right now is the way to display a sign, you have just entered without any enteres and spaces, what both <code>print a</code> and <code>print a,</code> does.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload