Aug-24-2020, 03:53 AM
I am trying to move from Perl to Python. Perl is a bit too esoteric for some of the more complex stuff I want to to in the future, and Python code is alot more intuitive with alot less gibberish.
However, there is a sore spot, and it threatens to be a deal killer for any type of text and filesystem operations: The Immutable String.
In Perl my typical method of string replacemtn is:
Its really great that Python has a nearly identical regex language, BUT....
Standard Python will not let me alter an existing string with string.replace or anything else I can seem to find. And I am not about to go through the hassle of converting to arrays (lists) and do replacements that way.
SO, the question is where there is a module, decorator or whatever is necessary to mutate strings and on a large scale? And on a simple straight line-by-line manner. Something like the Perl pattern operator or a function that allows mutation?
However, there is a sore spot, and it threatens to be a deal killer for any type of text and filesystem operations: The Immutable String.
In Perl my typical method of string replacemtn is:
$foo =~ s/bar/baz/ig; $foo =~ s/\-/\_/;g $foo =~ s/^\s+|s+$//g;These can go on for dozens and even hundreds of lines.
Its really great that Python has a nearly identical regex language, BUT....
Standard Python will not let me alter an existing string with string.replace or anything else I can seem to find. And I am not about to go through the hassle of converting to arrays (lists) and do replacements that way.
SO, the question is where there is a module, decorator or whatever is necessary to mutate strings and on a large scale? And on a simple straight line-by-line manner. Something like the Perl pattern operator or a function that allows mutation?