Re: URL 'special character' replacements

2006-01-09 Thread Richie Hindle
[Claude] > I have a huge list of URLs. These URLs all have ASCII codes for special > characters, like "%20" for a space or "%21" for an exclamation mark. You need urllib.unquote: >>> import urllib >>> help(urllib.unquote) Help on function unquote in module urllib: unquote(s) unquote('abc%20

Re: URL 'special character' replacements

2006-01-09 Thread Brett g Porter
Claude Henchoz wrote: > Hi guys > > I have a huge list of URLs. These URLs all have ASCII codes for special > characters, like "%20" for a space or "%21" for an exclamation mark. > > I've already googled quite some time, but I have not been able to find > any elegant way on how to replace these w

Re: URL 'special character' replacements

2006-01-09 Thread Claude Henchoz
Thanks guys, I like the urllib solution. Stupid me, looked at urllib reference, but thought that "quote" and "unquote" deal with _&_n_b_s_p_;_ style entities. -- http://mail.python.org/mailman/listinfo/python-list

Re: URL 'special character' replacements

2006-01-09 Thread Tim N. van der Leeuw
My outline for a solution would be: - Use StringIO or cStringIO for reading the original URLs character for character, and to build the result URLs character for character - When you read a '%' then read the next 2 character (should be digits!!!) and create a new string with them - The numbers li

Re: URL 'special character' replacements

2006-01-09 Thread Fredrik Lundh
Claude Henchoz wrote: > I have a huge list of URLs. These URLs all have ASCII codes for special > characters, like "%20" for a space or "%21" for an exclamation mark. > > I've already googled quite some time, but I have not been able to find > any elegant way on how to replace these with their 're

Re: URL 'special character' replacements

2006-01-09 Thread Duncan Booth
Claude Henchoz wrote: > I have a huge list of URLs. These URLs all have ASCII codes for special > characters, like "%20" for a space or "%21" for an exclamation mark. > > I've already googled quite some time, but I have not been able to find > any elegant way on how to replace these with their 'r

URL 'special character' replacements

2006-01-09 Thread Claude Henchoz
Hi guys I have a huge list of URLs. These URLs all have ASCII codes for special characters, like "%20" for a space or "%21" for an exclamation mark. I've already googled quite some time, but I have not been able to find any elegant way on how to replace these with their 'real' counterparts (" " a