while loop - Call the Python interactive interpreter from within a Python script -


Is there a way to start the Python interpreter from within a script, only to use python Is the same -i so that objects / namespaces etc. from the existing script should be retained? The reason for not using python -i is that the script starts a connection from an XML-RPC server, and I'm able to stop the entire program Required Error I can not loop until it is valid input, because apparently, I can not do anything like this:

  #! / Usr / bin / python -i # - * - Coding: UTF-8 - * - Import xmlrpclib # Create an object to represent our server. Server_url = str (raw_input ("server:"), while not server = xmlrpclib.Server (server_url): Unable to connect to print 'server  

because:' try again 'Other: Print' Xmlrpclib.Server object 'URL', server_url, '' created '' brake #pththon interpreter '__main___ Server '

 % chmod u + x ./rpcclient.py% ./rpclient.pyTestback (last call final): File "./rpcclient.py", line 8 while server No = xmlrpclib. Server (server_url): ^ syntax error: invalid syntax & gt; & Gt; & Gt;  

Unfortunately, python -i starts the interpreter only after printing a traceback, so I have to call the interactive interpreter in some way - execution of the script Instead of maintaining this server connection -

from inside the script, try to read the error message Is that? :)

= is assignment, you want the comparison operator == instead


Comments