Spread a statement over various lines
Manfred Lotz
ml_news at posteo.de
Wed Sep 18 23:13:29 EDT 2019
On Wed, 18 Sep 2019 22:01:34 +0200
"Ralf M." <Ralf_M at t-online.de> wrote:
> Am 17.09.2019 um 20:59 schrieb Manfred Lotz:
> > I have a function like follows
> >
> > def regex_from_filepat(fpat):
> > rfpat = fpat.replace('.', '\\.') \
> > .replace('%', '.') \
> > .replace('*', '.*')
> >
> > return '^' + rfpat + '$'
> >
> >
> > As I don't want to have the replace() functions in one line my
> > question is if it is ok to spread the statement over various lines
> > as shown above, or if there is a better way?
> >
> > Thanks.
> >
>
> Not related to your question, but:
> You seem to try to convert a Windows wildcard pattern to a regex
> pattern.
No, I'm on Linux.
Shortly, after I had posted the question I discovered fnmatch() in the
standard library, and I changed my code accordingly.
Nevertheless, I was happy to have asked the question as the
following discussion was very interesting for me.
--
Manfred
More information about the Python-list
mailing list