Here, concisely, is my view of the situation and my preferences. Mostly, I
won't give supporting arguments or evidence.

We can TRUNCATE either PRE or the POST, and similarly SUBTRACT.

SUBTRACT can raise a ValueError.
TRUNCATE always returns a value.

Interactive examples (not tested)
    >>> from somewhere import post_subtract
    >>> sub_ed = post_subtract('ed')
    >>> sub_ed('fred')
    >>> 'fr'
    >>> sub_ed('lead')
    ValueError

Similarly
    >>> trunc_ed('fred')
    'fr'
    >>> trunc_ed('lead')
    'lead'

Can be 'combined into one'
   >>> pre_truncate('app')('applet)
   'let'
    >>> pre_truncate('app')('paper')
    'paper'

Possibly
1.  Allow pre_truncate('app', 'applet'), perhaps with different spelling.
2. Allow '-' as a symbol for subtract. (Likely to be controversial.)

I'm not particularly attached to the names. But I definitely think
3. None of these are string methods. (So pure Python implementation
automatically backports.)
4. Encourage a 'two-step' process. This allow separation of concerns, and
encourage good names.

Supporting argument.
When we write
    pre_subtract(suffix, s)
the suffix has a special meaning. For example, it's the header. So in one
module define and test a routine remove_header. And in another module use
remove_header. That way, the user of remove_header only needs to know the
business purpose of the command. And the implementer needs to know only the
value of the header.

If the specs change, and the implementer needs to use regular expressions,
then this does not affect the user of remove_header.

I hope this helps. Maybe others would like to express their preferences.

-- 
Jonathan

-- 
Jonathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to