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
('%', '.') \
.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
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
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
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
\
> >.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
>
gex_from_filepat(fpat):
> > > rfpat = fpat.replace('.', '\\.') \
> > > .replace('%', '.') \
> > > .replace('*', '.*')
> > >
> > > return '^' + rfpat + '$'
> > >
> > >
> > > As
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
> >.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
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
'.') \
> > .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
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
>
>
> 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
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
.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
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
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:
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
18 matches
Mail list logo