osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Spread a statement over various lines


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