If what you posted is exactly what your code looks like, then you've got an indentation problem. Since Python doesn't use {}'s for code blocks, it uses indentation instead, and it's somewhat picky about indentation.
I think all the code after the first conn.request should line up with the conn.request. def WEP40_KEY(n): params = urllib.urlencode({}) headers = {"Connection": "Keep-Alive","Authorization": ""} conn = httplib.HTTPConnection(HOST) conn.request ("GET", "/w_sec.htm HTTP/1.1", params, headers) response = conn.getresponse() print response.status, response.reason params = urllib.urlencode({'wsecurity':"WEP",'wep_auth':"Shared+Key",'wepenc':"12 8+bit",'wep_key_no':"key1",'ascii_key1':"12345678901234567890123456",'as cii_key2':"",'ascii_key3':"",'ascii_key4':"",'passphrase':"",'wpa_psk':" 12345678",'key_lifetime':"65535",'wpa_enc':"TKIP",'save':"Save",'message ': "",'todo':""}) headers = {"Connection": "Keep-Alive","Authorization": ""} conn = httplib.HTTPConnection(HOST) conn.request("POST", "w_sec.htm", params, headers) response = conn.getresponse() print response.status, response.reason conn.close() It looks like your indenting 2 spaces. I believe the recommendation is 4 spaces. You might read the style guide. http://www.python.org/doc/essays/styleguide.html Out of curiosity, what editor are you using to write your code? You can configure many editors to automatically indent for you, change tabs to spaces, and set tabs to 4 spaces. Mike > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of govind goyal > Sent: Tuesday, April 17, 2007 9:29 AM > To: tutor@python.org > Subject: [Tutor] Error in my code > > Hi, > > I am executing following lines of code: > > def WEP40_KEY(n): > params = urllib.urlencode({}) > headers = {"Connection": "Keep-Alive","Authorization": ""} > conn = httplib.HTTPConnection(HOST) > conn.request ("GET", "/w_sec.htm HTTP/1.1", params, headers) > response = conn.getresponse() > print response.status, response.reason > params = > urllib.urlencode({'wsecurity':"WEP",'wep_auth':"Shared+Key",'w > epenc':"128+bit",'wep_key_no':"key1",'ascii_key1':"12345678901 234567890123456",'ascii_key2':"",'ascii_key3':"",'ascii_key4':"",'passph rase':"",'wpa_psk':"1234567> 8",'key_lifetime':"65535",'wpa_enc':"TKIP",'save':"Save",'mess > age': "",'todo':""}) > headers = {"Connection": "Keep-Alive","Authorization": ""} > conn = httplib.HTTPConnection(HOST) > conn.request("POST", "w_sec.htm", params, headers) > response = conn.getresponse() > print response.status, response.reason > conn.close() > > WEP40_KEY(sys.argv) > > > > I am getting following error: > > > C:\Documents and > Settings\Govindadya\Desktop\Marvell>Marvell_WEP40.py 192.168.1. > 16 > File "C:\Documents and > Settings\Govindadya\Desktop\Marvell\Marvell_WEP40.py", > line 41 > response = conn.getresponse() > ^ > IndentationError: unindent does not match any outer indentation level > > > > Can anybody help me out on this? > > Best Regards, > > Govind > > > > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor