EvilZone

Programming and Scripting => Scripting Languages => : Ragehottie June 11, 2012, 12:08:13 AM

: [Python] Constantly get input/output
: Ragehottie June 11, 2012, 12:08:13 AM
I am working on a minecraft server wrapper and I just need something so I can constantly input commands and constantly get the output for commands/other things. Any help would be awesome.
: Re: [Python] Constantly get input/output
: NeX June 11, 2012, 12:45:29 AM
:
while(1):
var = raw_input("User input: ")
print "User input is: ", var

Does that help?
: Re: [Python] Constantly get input/output
: Ragehottie June 11, 2012, 12:51:48 AM
No, because it might need to output something before it gets input or vice versa
: Re: [Python] Constantly get input/output
: NeX June 11, 2012, 12:54:47 AM
I seem to not understand the phenomenon of writing something to output which relies on the input, BEFORE getting the input. Either that, or you need something like threads? One for writing the output based on previous calculations that include the last input and another for getting the input whenever you need it.
: Re: [Python] Constantly get input/output
: s3my0n June 11, 2012, 01:20:19 AM
: (python)
while(1):
        if need_to_output:
            print output
var = raw_input("User input: ")
print "User input is: ", var
?
: Re: [Python] Constantly get input/output
: Ragehottie June 11, 2012, 03:05:35 AM
: (python)
while(1):
        if need_to_output:
            print output
   var = raw_input("User input: ")
   print "User input is: ", var
?


Kinda. But I need it to not get hung on getting the input. I think I need to use threads maybe?
: Re: [Python] Constantly get input/output
: s3my0n June 11, 2012, 03:40:40 AM

Kinda. But I need it to not get hung on getting the input. I think I need to use threads maybe?

Yeah you need to use threads. One thread changes the map the other one listens for user input.
: Re: [Python] Constantly get input/output
: techb June 11, 2012, 04:51:22 AM
Kinda. But I need it to not get hung on getting the input. I think I need to use threads maybe?

That hung up is called blocking. You will need threads. Internet protocols can also block, so without knowing more information of what your wanting to do, I will suggest threading.