[Python-Dev] Alternative name for str.partition()
Jim Jewett
jimjjewett at gmail.com
Wed Aug 31 20:43:02 CEST 2005
[In http://mail.python.org/pipermail/python-dev/2005-August/055880.html ]
Andrew Durdin wrote:
> one of the "fixed stdlib" examples that Raymond
> posted actually uses rpartition and partition in two consecutive lines
Even with that leadin, even right next to each other, it took me a bit of
time to see the difference between rest.rpartition and rest.partition.
> rest, _, query = rest.rpartition('?')
> script, _, rest = rest.partition('/')
Shortening the names helps, because a single letter matters more.
> rest, _, query = rest.rpart('?')
> script, _, rest = rest.part('/')
A different-looking word (such as Greg's suggestion) might be even
better, if the word also works on its own.
> rest, _, query = rest.rsplit_at('?')
> script, _, rest = rest.split_at('/')
-jJ
More information about the Python-Dev
mailing list