A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-May/065264.html below:

[Python-Dev] partition() variants

[Python-Dev] partition() variants [Python-Dev] partition() variantsWalter Dörwald walter at livinglogic.de
Fri May 26 23:09:22 CEST 2006
Guido van Rossum wrote:
> On 5/26/06, Walter Dörwald <walter at livinglogic.de> wrote:
> [...]
>> And what happens if the separator is an instance of a subclass?
>>
>> class s2(str):
>>     def __repr__(self):
>>         return "s2(%r)" % str(self)
>>
>> print "foobar".partition(s2("o"))
>>
>> Currently this prints:
>>    ('f', s2('o'), 'obar')
>> Should this be
>>    ('f', 'o', 'obar')
>> or not?
>>
>> And what about:
>>    print s2("foobar").partition("x")
>> Currently this prints
>>    (s2('foobar'), '', '')
>
> These are both fine with me.

split() doesn't behave that way:

>>> s2("foobar").split("x")
['foo']

Servus,
   Walter



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