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/055811.html below:

[Python-Dev] partition() (was: Remove str.find in 3.0?)

[Python-Dev] partition() (was: Remove str.find in 3.0?) [Python-Dev] partition() (was: Remove str.find in 3.0?)Nick Coghlan ncoghlan at gmail.com
Tue Aug 30 14:42:20 CEST 2005
Pierre Barbier de Reuille wrote:
> What I'm talking about is consistency. In most cases in Python, or at
> least AFAIU, error testing is avoided and exception launching is
> preferred mainly for efficiency reasons. So my question remains: why
> prefer for that specific method returning an "error" value (i.e. an
> empty separator) against an exception ?

Because, in many cases, there is more to it than just the separator not being 
found.

Given a non-empty some_str and some_sep:

   head, sep, tail = some_str.partition(some_sep)

There are actually five possible results:

   head and not sep and not tail (the separator was not found)
   head and sep and not tail (the separator is at the end)
   head and sep and tail (the separator is somewhere in the middle)
   not head and sep and tail (the separator is at the start)
   not head and sep and not tail (the separator is the whole string)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
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