exec / execfile namespace problem

Karan Vasudeva karanvasudevaNOkaSPAM at usa.net.invalid
Sat Nov 6 11:26:17 CET 1999


Hi,

I'm trying to do this:
execfile('cool.py')

and this:

import fileinput
chunk = ''
for line in fileinput.input('cool.py'):
   chunk = chunk + line
exec(chunk)

where 'cool.py' is this: (in part)
import httplib
import time
import whrandom
h = httplib.HTTP('')
h.putrequest('GET', '/favicon.ico')

This fails with this error message at the command prompt:
Traceback (innermost last):
  File "testSlave.py", line 1, in ?
    execfile('cool.py')
  File "cool.py", line 8, in ?
    h.putrequest('GET', '/favicon.ico')
  File "httplib.py", line xx, in putrequest
    self.send(str)
  File "httplib.py", line xx, in send
    self.sock.send(str)
AttributeError: sock

(I changed two line numbers to xx, they were different but thats
irrelevant)

I've tried to change self.sock to sock, but that didn't help. Guess
I'm stumbling around in the dark being an absolute newbie at this.
Any help would be appreciated.

Regards,
Karan.



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!





More information about the Python-list mailing list