A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-August/055864.html below:

[Python-Dev] Proof of the pudding: str.partition()

[Python-Dev] Proof of the pudding: str.partition()Raymond Hettinger raymond.hettinger at verizon.net
Tue Aug 30 22:27:48 CEST 2005
[Fredrik Lundh]
> it is, however, a bit worrying that you end up ignoring one or more
> of the values in about 50% of your examples...
 
It drops to about 25% when you skip the ones that don't care about the
found/not-found field:


> > !     _, sep, port = host.partition(':')
> > !             head, sep, _ = path.rpartition('/')
> > !                 line, _, _ = line.partition(';')  # strip
> > !         pname, found, _ = pname.rpartition('.')
> > !             line, _, _ = line.partition('#')
> > !         filename, _, _ = filename.partition(chr(0))

The remaining cases don't bug me much.  They clearly say, ignore the
left piece or ignore the right piece.  We could, of course, make these
clearer and more efficient by introducing more methods:
   
   s.before(sep)  --> (left, sep)
   s.after(sep)   --> (right, sep)
   s.rbefore(sep) --> (left, sep)
   s.r_after(sep) --> (right, sep)

But who wants all of that?


Raymond

More information about the Python-Dev mailing list

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