[Python-3000] find -> index patch
Nick Coghlan
ncoghlan at gmail.com
Thu Aug 24 11:38:44 CEST 2006
Jack Diederich wrote:
> If folks like the way this partial set looks I'll convert the rest.
+1 from here (beautifying the standard lib was one of the justifications for
partition, after all).
> ------------------------------------------------------------------------
>
> Index: Lib/CGIHTTPServer.py
> ===================================================================
> --- Lib/CGIHTTPServer.py (revision 51530)
> +++ Lib/CGIHTTPServer.py (working copy)
> @@ -106,16 +106,9 @@
> def run_cgi(self):
> """Execute a CGI script."""
> dir, rest = self.cgi_info
> - i = rest.rfind('?')
> - if i >= 0:
> - rest, query = rest[:i], rest[i+1:]
> - else:
> - query = ''
> - i = rest.find('/')
> - if i >= 0:
> - script, rest = rest[:i], rest[i:]
> - else:
> - script, rest = rest, ''
> + (rest, sep, query) = rest.rpartition('?')
> + (rest, sep, script) = rest.partition('/')
> + rest = sep + rest # keep the slash
rest & script are back to front on the second line of the new bit.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list