Passing info to function used in re.sub

Dieter Maurer dieter at handshake.de
Mon Sep 4 15:37:30 EDT 2023


Jan Erik Moström wrote at 2023-9-3 18:10 +0200:
>I'm looking for some advice for how to write this in a clean way
> ...
>The "problem" is that I've currently written some code that works but it uses global variables ... and I don't like global variables. I assume there is a better way to write this, but how?

You could define a class with a `__call__` method
and use an instance of the class as replacement.
The class and/or instance can provide all relevant information via
attributes.



More information about the Python-list mailing list