Raymond Hettinger wrote: > Looking at sample code transformations shows that the high-power > mxTextTools and re approaches do not simplify code that currently uses > s.find(). In contrast, the proposed partition() method is a joy to use > and has no surprises. The following code transformation shows > unbeatable simplicity and clarity.
+1 This doesn't cause any backward compatible issues as well! > --- From CGIHTTPServer.py --------------- > > 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, '' > . . . > > > def run_cgi(self): > """Execute a CGI script.""" > dir, rest = self.cgi_info > rest, _, query = rest.rpartition('?') > script, _, rest = rest.partition('/') > . . . +1 Much easier to read and understand! Cheers, Ron _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com