[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020年3月24日 15:14:28 -0700

Le mar. 24 mars 2020 à 20:06, Paul Sokolovsky <[email protected]> a écrit :
> === config.something ===
> # If you'd like to remove some prefix from your lines, set it here
> REMOVE_PREFIX = ""
> ======
>
> === src.py ===
> ...
> line = line.cutprefix(config.REMOVE_PREFIX)
> ...
> ======
Just use:
if config.REMOVE_PREFIX:
 line = line.cutprefix(config.REMOVE_PREFIX)
Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/VUMXNEHLDNKOIAFXVV6CPSRBSAEB5AEI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to