Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 700889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:32:54+00:00 2026-05-14T03:32:54+00:00

want to ask user to input something but not want to wait forever. There

  • 0

want to ask user to input something but not want to wait forever. There is a solution for Linux, Keyboard input with timeout in Python, but I am in windows environment. anybody can help me?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:32:55+00:00Added an answer on May 14, 2026 at 3:32 am

    Credit to Alex Martelli

    Unfortunately, on Windows,
    select.select works only on sockets,
    not ordinary files nor the console.
    So, if you want to run on Windows, you
    need a different approach. On Windows
    only, the Python standard library has
    a small module named msvcrt, including
    functions such as msvcrt.kbhit which
    tells you whether any keystroke is
    waiting to be read. Here, you might
    sys.stdout.write the prompt, then
    enter a small loop (including a
    time.sleep(0.2) or so) which waits to
    see whether the user is pressing any
    key — if so then you can
    sys.stdin.readline etc, but if after
    your desired timeout is over no key
    has been hit, then just return the
    empty string from your function.

    All of this assumes that if the user
    has STARTED typing something then you
    want to wait indefinitely (not timeout
    in the middle of their entering their
    answer!). Otherwise, you have more
    work to do, since you must ensure that
    the user has hit a Return (which means
    you must peek at exactly what’s in
    sys.stdin, resp. use msvcrt.getch, one
    character at a time). Fortunately, the
    slightly simpler approach of waiting
    indefinitely if the user has started
    entering seems to be the preferable
    one from a user interface viewpoint —
    it lets you deal with unattended
    consoles as you desire, yet IF the
    user is around at all it gives the
    user all the time they want to
    COMPLETE their answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to ask the user for input in console. He'll be writing down
Using Python v2.x, I have 3 variables that I want to ask the user
I want to ask the user to input a variable and check it is
Alright so in Java I want to ask the user for a time in
In my GWT application, I want to ask a user confirmation when he navigates
Suppose I ask the user do you want to run in 32bit mode or
I want to ask you something. I make the application web with the Google
I want to ask pro developers out there that how they manage a big
I want to ask if is there any faster method how to make this
In my lua program, i want to stop and ask user for confirmation before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.