Re: Spread a statement over various lines

2019-09-19 Thread Ralf M.
Am 18.09.2019 um 22:24 schrieb Alexandre Brault: On 2019-09-18 4:01 p.m., Ralf M. wrote: I don't know the exact rules of Windows wildcards, so there may be even more cases of unexpected behavior. If anyone knows where to find the complete rules (or a python module that implements them), I

Re: Spread a statement over various lines

2019-09-19 Thread Ralf M.
('%', '.') \ .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

Re: Spread a statement over various lines

2019-09-19 Thread Peter Otten
Manfred Lotz wrote: >> Where does '%' come from? >> > > '%' was a mistake as I had replied myself to my initial question. Oh, sorry. I missed that. -- https://mail.python.org/mailman/listinfo/python-list

Re: Spread a statement over various lines

2019-09-19 Thread Manfred Lotz
On Thu, 19 Sep 2019 08:36:04 +0200 Peter Otten <__pete...@web.de> wrote: > Manfred Lotz wrote: > > >> 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

Re: Spread a statement over various lines

2019-09-19 Thread Peter Otten
Manfred Lotz wrote: >> 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. I

Re: Spread a statement over various lines

2019-09-18 Thread Manfred Lotz
\ > >.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 >

Re: Spread a statement over various lines

2019-09-18 Thread codewizard
gex_from_filepat(fpat): > > > rfpat = fpat.replace('.', '\\.') \ > > > .replace('%', '.') \ > > > .replace('*', '.*') > > > > > > return '^' + rfpat + '$' > > > > > > > > > As

Re: Spread a statement over various lines

2019-09-18 Thread Alexandre Brault
gt;>    .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 bett

Re: Spread a statement over various lines

2019-09-18 Thread Chris Angelico
> >.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 abov

Re: Spread a statement over various lines

2019-09-18 Thread Ralf M.
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. However, wildcards sometimes

Re: Spread a statement over various lines

2019-09-18 Thread Manfred Lotz
'.') \ > > .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 > > a

Re: Spread a statement over various lines

2019-09-18 Thread Manfred Lotz
t; .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 sho

Re: Spread a statement over various lines

2019-09-18 Thread Wolfgang Maier
> > > 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? > One problem with explicit line continuation using \ is that it is dependent on the backslash

Re: Spread a statement over various lines

2019-09-18 Thread Peter Otten
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? Sometimes you can avoid method-chaining: >>> REP = str.maketrans({".": "\\.", &q

Re: Spread a statement over various lines

2019-09-17 Thread Manfred Lotz
.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

Re: Spread a statement over various lines

2019-09-17 Thread Dan Sommers
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? Is that way okay? Sure. Are there other ways? Sure. To isolate each replace() function on its own line, and to eliminate the clutte

Re: Spread a statement over various lines

2019-09-17 Thread Manfred Lotz
On Tue, 17 Sep 2019 20:59:47 +0200 Manfred Lotz wrote: > I have a function like follows > > def regex_from_filepat(fpat): > rfpat = fpat.replace('.', '\\.') \ > .replace('%', '.') \ Not related to my question but the second replace must be:

Spread a statement over various lines

2019-09-17 Thread Manfred Lotz
is if it is ok to spread the statement over various lines as shown above, or if there is a better way? Thanks. -- Manfred -- https://mail.python.org/mailman/listinfo/python-list