Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Nathan Schneider
On Sat, Dec 29, 2018 at 12:30 AM Alexander Heger wrote: > for regular strings one can write > > "aaa" + "bbb" > > which also works for f-strings, r-strings, etc.; in regular expressions, > there is, e.g., parameter counting and references to numbered matches. How > would that be dealt with in a

Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Steven D'Aprano
On Sat, Dec 29, 2018 at 04:29:32PM +1100, Alexander Heger wrote: > for regular strings one can write > > "aaa" + "bbb" > > which also works for f-strings, r-strings, etc.; in regular expressions, > there is, e.g., parameter counting and references to numbered matches. How > would that be dealt

Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Alexander Heger
for regular strings one can write "aaa" + "bbb" which also works for f-strings, r-strings, etc.; in regular expressions, there is, e.g., parameter counting and references to numbered matches. How would that be dealt with in a compound p-string? Either it would have to re-compiled or not,

Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Ma Lin
On 18-12-28 22:54, Joao S. O. Bueno wrote: Sorry for sounding over-reactive, but yes, this could make Python look like Perl. Yes, this may introduce Perl's style irreversibly, we need to be cautious about this. I'm thinking, if people ask these questions in their mind when reading a piece of

Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Joao S. O. Bueno
I am a full -1 on this idea - > Two shortcomings: > > 1, Elevating a class in a module (re.Pattern) to language level, this > sounds not very natural. > This makes Python looks like Perl. > > 2, We can't use regex module as a drop-in replacement: import regex as re > IMHO, I would like to see

[Python-ideas] In fact, I'm a bit worry about this literal p""

2018-12-28 Thread Ma Lin
Maybe this literal will encourage people to finish tasks using regex, even lead to abuse regex, will this change Python's style? What's worse is, people using mixed manners in the same project: one_line.split(',') ... p','.split(one_line) Maybe it will break the Python's style, reduce code

Re: [Python-ideas] Add regex pattern literal p""

2018-12-28 Thread Ma Lin
Reply to Stefan Behnel and Chris Angelico. On 18-12-27 22:42, Stefan Behnel wrote: >  >>> import pickle, re >  >>> p = re.compile("[abc]") >  >>> pickle.dumps(p) >  b'\x80\x03cre\n_compile\nq\x00X\x05\x00\x00\x00[abc]q\x01K \x86q\x02Rq\x03.' > > What this does, essentially, is to make the