Spread a statement over various lines

Manfred Lotz ml_news at posteo.de
Tue Sep 17 14:59:47 EDT 2019


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.

-- 
Manfred
 




More information about the Python-list mailing list