Thanks the encode method really helps.

Alan Gauld <[EMAIL PROTECTED]> wrote: "ammar azif"  wrote

> Actually i wanted to write a http client using just he low level 
> socket module.

I won;t ask why! But the httplib module probably does what you want
just in case you dodn't realize it existed...

> The program will prompt the user asking for input and the
> use will type http commands like
> 'GET /index.html HTTP/1.0\r\nHost: somehost\r\n\r\n'

OK, So you want the user to acrtually type \,n,\,n and you
will then send that string to be interpreted as newlines?

> when i use the raw_input function , the string that i get is
> 'GET /index.html HTTP/1.0\\r\\nHost: somehost\\r\\n\\r\\n'

The double \\ doesn''t actually exist its just Python telling you
that it is a literal \ character not an escaped sequence.
As I said earlier if you check the len() of the string it will
only have one character per backslash.

I think it's already doing what you want!
You just need to turn the \n's that the user entered into
newline characters, Kent has shown you how to do that
with the decode() method...

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


       
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to