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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4