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

[Python-Dev] partition()

[Python-Dev] partition() [Python-Dev] partition()Michael Hudson mwh at python.net
Tue Aug 30 19:43:18 CEST 2005
Nick Coghlan <ncoghlan at gmail.com> writes:

> Michael Hudson wrote:
>> partition() works for me.  It's not perfect, but it'll do.  The idea
>> works for me rather more; it even simplifies the 
>> 
>> if s.startswith(prefix):
>>     t = s[len(prefix):]
>>     ...
>
> How would you do it? Something like:
>
>    head, found, tail = s.partition(prefix)
>    if found and not head:
>      ...
>
> I guess I agree that's an improvement - only a slight one, though.

Yes.  I seem to fairly often[1] do this with prefix as a literal so
only having to mention it once would be a win for me.

Cheers,
mwh

[1] But not often enough to have defined a function to do this job, it
    seems.

-- 
  <teratorn> I must be missing something. It is not possible to be
             this stupid.  
  <Yhg1s> you don't meet a lot of actual people, do you?
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