By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

check if there is data in stdin without blocking

P: n/a
hg
Hi,

Is there a way ? ... select ?

hg

Jan 15 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
hg
hg wrote:
Hi,

Is there a way ? ... select ?

hg
PS:

import sys
import select

l_r = select.select([sys.stdin],[],[],0)

gives me:
File "select.py", line 2, in ?
import select
File "/home/philippe/Desktop/select.py", line 4, in ?
l_r = select.select([sys.stdin],[],[],0)
TypeError: 'module' object is not callable
Jan 15 '07 #2

P: n/a
hg a écrit :
hg wrote:
>Hi,

Is there a way ? ... select ?

hg
PS:

import sys
import select

l_r = select.select([sys.stdin],[],[],0)

gives me:
File "select.py", line 2, in ?
import select
File "/home/philippe/Desktop/select.py", line 4, in ?
l_r = select.select([sys.stdin],[],[],0)
TypeError: 'module' object is not callable

Wont work under Windows:
>>help(select.select)
....<zip>...
*** IMPORTANT NOTICE ***
On Windows, only sockets are supported; on Unix, all file descriptors.

If under Unix, maybe sys.stdin.fileno() is a valid descriptor for
select. Just test it.

And if under Windows, you may take a look at
22.1 msvcrt - Useful routines from the MS VC++ runtime
22.1.2 Console I/O
kbhit( ) - Return true if a keypress is waiting to be read.
Jan 15 '07 #3

P: n/a
hg
Laurent Pointal wrote:
hg a écrit :
>hg wrote:
>>Hi,

Is there a way ? ... select ?

hg
PS:

import sys
import select

l_r = select.select([sys.stdin],[],[],0)

gives me:
File "select.py", line 2, in ?
import select
File "/home/philippe/Desktop/select.py", line 4, in ?
l_r = select.select([sys.stdin],[],[],0)
TypeError: 'module' object is not callable


Wont work under Windows:
>>>help(select.select)
...<zip>...
*** IMPORTANT NOTICE ***
On Windows, only sockets are supported; on Unix, all file descriptors.

If under Unix, maybe sys.stdin.fileno() is a valid descriptor for
select. Just test it.

And if under Windows, you may take a look at
22.1 msvcrt - Useful routines from the MS VC++ runtime
22.1.2 Console I/O
kbhit( ) - Return true if a keypress is waiting to be read.

Well I'm testing under Linux but need support under Windows ... is there any
way to poll stdin somehow under both plateform ?

thanks,

hg

Jan 15 '07 #4

P: n/a
hg wrote:
import select
[...]
File "/home/philippe/Desktop/select.py", line 4, in ?
Consider which module Python is trying to import here: the standard
library select module or your own program?

Paul

Jan 15 '07 #5

P: n/a
hg
Paul Boddie wrote:
hg wrote:
>import select

[...]
> File "/home/philippe/Desktop/select.py", line 4, in ?

Consider which module Python is trying to import here: the standard
library select module or your own program?

Paul
Argh !!!! ;-)

thanks
Jan 15 '07 #6

P: n/a
At Monday 15/1/2007 05:55, hg wrote:
>Well I'm testing under Linux but need support under Windows ... is there any
way to poll stdin somehow under both plateform ?
I think you may want this portable getch function:
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892>
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 15 '07 #7

P: n/a
hg
Gabriel Genellina wrote:
At Monday 15/1/2007 05:55, hg wrote:
>>Well I'm testing under Linux but need support under Windows ... is there
any way to poll stdin somehow under both plateform ?

I think you may want this portable getch function:
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892>
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
will take a look, thanks.

hg

Jan 15 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.