[Tutor] ascii encoding

2005-01-24 Thread Luis N
How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. I've hunted through the standard library, but nothing seemed to jump out. Thank You. ___ Tutor maillist -

Re: [Tutor] ascii encoding

2005-01-24 Thread Max Noel
On Jan 24, 2005, at 23:29, Luis N wrote: How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. I've hunted through the standard library, but nothing seemed to jump out. The pathname2url in urllib seems to do

Re: [Tutor] ascii encoding

2005-01-24 Thread Chad Crabtree
I got this from spyce http://spyce.sourceforge.net _url_ch = re.compile(r'[^A-Za-z0-9_.!~*()-]') # RFC 2396 section 2.3 def url_encode(o, **kwargs): '''Return URL-encoded string.''' return _url_ch.sub(lambda match: %%%02X % ord(match.group(0)), str(o)) It was just the first thing I found in

Re: [Tutor] ascii encoding

2005-01-24 Thread Kent Johnson
Luis N wrote: How would I best turn this string: '2005-01-24 00:00:00.0' into this string: '2005%2D01%2D24%2000%3A00%3A00%2E0' In order to call a URL. urllib.quote_plus() is intended for this purpose though it doesn't have the result you ask for: import urllib s='2005-01-24 00:00:00.0'

Re: [Tutor] ascii encoding

2005-01-24 Thread Kent Johnson
Kent Johnson wrote: import re def hexify(match): ... return '%%%X' % ord(match.group(0)) Ah, should be '%%%02X' ... Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Seek advise to code Re: Fw: Please submit to tutor list: dictionary update prob

2005-01-24 Thread Eri Mendz
Kent Johnson kent37 at tds.net writes: [snip] You still aren't doing anything with newdic. The absence of 'newdic' in the code after 'read.close()' should be a clue I think you want to overwrite the saved dict, but with the new dict instead of with a filename string... Hi Kent,