Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-23 Thread Mikhail V
On 23 April 2017 at 05:03, MRAB wrote: > On 2017-04-22 23:30, Mikhail V wrote: >> >> On 20 April 2017 at 23:54, MRAB wrote: >> > On 2017-04-20 22:03, Mikhail V wrote: >> >> >> >> On 20 April 2017 at 22:43, Random832 wrote: >> >>> [snip] >> >>> >> >>> The best solution I can think of is to have a

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread MRAB
On 2017-04-22 23:30, Mikhail V wrote: On 20 April 2017 at 23:54, MRAB wrote: > On 2017-04-20 22:03, Mikhail V wrote: >> >> On 20 April 2017 at 22:43, Random832 wrote: >>> [snip] >>> >>> The best solution I can think of is to have a text editor designed to >>> parse a string literal, spawn a nes

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 12:30 PM, eryk sun wrote: > The X terminals that I've used make it easy to copy text to the > clipboard. For Windows, it's a pain prior to Windows 10 since the > legacy console only does rectangular selection. The Windows 10 console > does line-wrapped selection. This is t

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread eryk sun
On Sun, Apr 23, 2017 at 2:06 AM, Mikhail V wrote: > > But are you joking, right? Even if it worked, how can this be convinient, > e.g. in console one cannot even select and copy paste easily. The X terminals that I've used make it easy to copy text to the clipboard. For Windows, it's a pain prior

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 12:06 PM, Mikhail V wrote: > Don't know, all I see is "SyntaxError: invalid syntax" if I paste > there some text. > Try to paste e.g. this: > "ffmpeg -i "D:\VIDEO\exp\intro.mp4" -vf "crop=1280:720:0:40, > scale=640:360" -pix_fmt yuv420p "D:\ART\0MASTER_UMST\yt_pico.mp4""

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 23 April 2017 at 02:33, Chris Angelico wrote: > On Sun, Apr 23, 2017 at 10:19 AM, Mikhail V wrote: >> On 23 April 2017 at 00:48, Chris Angelico wrote: >>> On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: The purpose is simple: reduce manual work to escape special characters in str

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 10:19 AM, Mikhail V wrote: > On 23 April 2017 at 00:48, Chris Angelico wrote: >> On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: >>> The purpose is simple: reduce manual work to escape special >>> characters in string literals (and escape non-ASCII characters). >>> >>>

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 23 April 2017 at 00:48, Chris Angelico wrote: > On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: >> The purpose is simple: reduce manual work to escape special >> characters in string literals (and escape non-ASCII characters). >> >> Simple usage scenario: >> - I have a long command-line stri

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: > The purpose is simple: reduce manual work to escape special > characters in string literals (and escape non-ASCII characters). > > Simple usage scenario: > - I have a long command-line string in some text editor. > - Copy this string and paste in

String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 20 April 2017 at 23:54, MRAB wrote: > On 2017-04-20 22:03, Mikhail V wrote: >> >> On 20 April 2017 at 22:43, Random832 wrote: >>> [snip] >>> >>> The best solution I can think of is to have a text editor designed to >>> parse a string literal, spawn a nested editor with the unescaped >>> conten

Re: Rawest raw string literals

2017-04-22 Thread Tim Chase
On 2017-04-22 23:13, Mikhail V wrote: > k = r"abc > def" > > gives an error: > > k = r"abc > ^ > SyntaxError: EOL while scanning string literal > > So one could define a rule, that a raw string *must* > be terminated by the sequence quote + newline. > In theory. Though one

Re: Rawest raw string literals

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 7:13 AM, Mikhail V wrote: > So one could define a rule, that a raw string *must* > be terminated by the sequence quote + newline. > In theory. Then how would you pass one as a function parameter? func(r"" ) Ugh. Ugly. ChrisA -- https://mail.python.org/mailman/listi

Re: Rawest raw string literals

2017-04-22 Thread Mikhail V
On 20 April 2017 at 18:40, Grant Edwards wrote: > On 2017-04-20, Mikhail V wrote: >> On 20 April 2017 at 17:59, Grant Edwards wrote: >>> On 2017-04-20, Mikhail V wrote: Quite often I need raw string literals for concatenating console commands. I want to input them exactly as they are

Re: Rawest raw string literals

2017-04-21 Thread Jussi Piitulainen
Tim Chase writes: > On 2017-04-21 08:23, Jussi Piitulainen wrote: >> Tim Chase writes: >>> Bash: >>> cat <>> "single and double" with \ and / >>> EOT >>> >>> PS: yes, bash's does interpolate strings, so you still need to do >>> escaping within, but the arbitrary-user-specified-delimiter ide

Re: Rawest raw string literals

2017-04-21 Thread Tim Chase
On 2017-04-21 08:23, Jussi Piitulainen wrote: > Tim Chase writes: >> Bash: >> cat <> "single and double" with \ and / >> EOT >> >> PS: yes, bash's does interpolate strings, so you still need to do >> escaping within, but the arbitrary-user-specified-delimiter idea >> still holds. > > If you

Re: Rawest raw string literals

2017-04-20 Thread Jussi Piitulainen
Tim Chase writes: > A number of tools use a custom quote-string: > > Bash: > > cat < "single and double" with \ and / > EOT [snip] > PS: yes, bash's does interpolate strings, so you still need to do > escaping within, but the arbitrary-user-specified-delimiter idea still > holds. If you p

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-21 01:11, Tim Chase wrote: On 2017-04-20 16:40, Grant Edwards wrote: How can there exist a "universal solution" even in theory? There has to be some sort of "end of literal" terminator character sequence. That means there has to be some sort of escaping mechanism when that "end of l

Re: Rawest raw string literals

2017-04-20 Thread Tim Chase
On 2017-04-20 16:40, Grant Edwards wrote: > How can there exist a "universal solution" even in theory? > > There has to be some sort of "end of literal" terminator character > sequence. That means there has to be some sort of escaping > mechanism when that "end of literal" sequence appears in the

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-20 22:03, Mikhail V wrote: On 20 April 2017 at 22:43, Random832 wrote: On Thu, Apr 20, 2017, at 16:01, Grant Edwards wrote: On 2017-04-20, MRAB wrote: > There _is_ a "universal solution"; it's called a Hollerith constant. :-) Wow, I haven't seen one of those in a _long_ time -- pr

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 7:37 AM, Stefan Ram wrote: > Mikhail V writes: >>But the less probable it is, the more complex or ugly would the tag >>become. >>E.g. curly braces {} seems to be much less frequent characters >>for filenames and command line arguments. > > When one uses brackets to delim

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 22:43, Random832 wrote: > On Thu, Apr 20, 2017, at 16:01, Grant Edwards wrote: >> On 2017-04-20, MRAB wrote: >> > There _is_ a "universal solution"; it's called a Hollerith constant. :-) >> >> Wow, I haven't seen one of those in a _long_ time -- probably about 45 >> years. I

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 19:27, Chris Angelico wrote: > On Fri, Apr 21, 2017 at 2:26 AM, wrote: >> I find this:- >> >> s = r"ffmpeg -i '\\server-01\D\SER_Bigl.mpg' " >> >> vastly superior. > > It's semantically different though. I don't know whether single quotes > are valid in that context, on Wind

Re: Rawest raw string literals

2017-04-20 Thread Random832
On Thu, Apr 20, 2017, at 16:01, Grant Edwards wrote: > On 2017-04-20, MRAB wrote: > > There _is_ a "universal solution"; it's called a Hollerith constant. :-) > > Wow, I haven't seen one of those in a _long_ time -- probably about 45 > years. I think the first FORTAN implementation I used was WA

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, MRAB wrote: > On 2017-04-20 17:40, Grant Edwards wrote: > >> There has to be some sort of "end of literal" terminator character >> sequence. That means there has to be some sort of escaping mechanism >> when that "end of literal" sequence appears in the literal itself. >> > There

Re: Rawest raw string literals

2017-04-20 Thread MRAB
On 2017-04-20 17:40, Grant Edwards wrote: On 2017-04-20, Mikhail V wrote: On 20 April 2017 at 17:59, Grant Edwards wrote: On 2017-04-20, Mikhail V wrote: Quite often I need raw string literals for concatenating console commands. I want to input them exactly as they are in python sources. T

Re: Rawest raw string literals

2017-04-20 Thread Arthur Havlicek
No escaping is not something possible, in your suggested syntax ") is ambigous. E.g. raw("abcd")") is ambigous. Any sequence delimited string involves escaping, the only thing that wouldnt would be size-defined strings but they are impractical. Le 20/04/2017 à 18:03, Mikhail V a écrit : On 2

Re: Rawest raw string literals

2017-04-20 Thread eryk sun
On Thu, Apr 20, 2017 at 5:27 PM, Chris Angelico wrote: > On Fri, Apr 21, 2017 at 2:26 AM, wrote: >> I find this:- >> >> s = r"ffmpeg -i '\\server-01\D\SER_Bigl.mpg' " >> >> vastly superior. > > It's semantically different though. I don't know whether single quotes > are valid in that context, o

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 2:26 AM, wrote: > I find this:- > > s = r"ffmpeg -i '\\server-01\D\SER_Bigl.mpg' " > > vastly superior. It's semantically different though. I don't know whether single quotes are valid in that context, on Windows. ChrisA -- https://mail.python.org/mailman/listinfo/pyth

Re: Rawest raw string literals

2017-04-20 Thread breamoreboy
On Thursday, April 20, 2017 at 4:59:48 PM UTC+1, Grant Edwards wrote: > On 2017-04-20, Mikhail V wrote: > > Quite often I need raw string literals for concatenating console commands. > > I want to input them exactly as they are in python sources. > > > > There is r"" string, but it is obviously not

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V wrote: > On 20 April 2017 at 17:44, Mikhail V wrote: >> Quite often I need raw string literals for concatenating console commands. >> I want to input them exactly as they are in python sources. >> >> There is r"" string, but it is obviously not enough because e.g. this: >

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V wrote: > On 20 April 2017 at 17:59, Grant Edwards wrote: >> On 2017-04-20, Mikhail V wrote: >>> Quite often I need raw string literals for concatenating console commands. >>> I want to input them exactly as they are in python sources. >>> >>> There is r"" string, but it

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 2:16 AM, Mikhail V wrote: > On 20 April 2017 at 17:59, Grant Edwards wrote: >> On 2017-04-20, Mikhail V wrote: >>> Quite often I need raw string literals for concatenating console commands. >>> I want to input them exactly as they are in python sources. >>> >>> There is r

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 17:59, Grant Edwards wrote: > On 2017-04-20, Mikhail V wrote: >> Quite often I need raw string literals for concatenating console commands. >> I want to input them exactly as they are in python sources. >> >> There is r"" string, but it is obviously not enough because e.g. thi

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 2:03 AM, Mikhail V wrote: > On 20 April 2017 at 17:55, Chris Angelico wrote: >> On Fri, Apr 21, 2017 at 1:44 AM, Mikhail V wrote: >>> What I think: why there is no some built-in function, for example like: >>> s = raw("ffmpeg -i "\\server-01\D\SER_Bigl__"") >>> >>> which

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 17:55, Chris Angelico wrote: > On Fri, Apr 21, 2017 at 1:44 AM, Mikhail V wrote: >> What I think: why there is no some built-in function, for example like: >> s = raw("ffmpeg -i "\\server-01\D\SER_Bigl__"") >> >> which would just need *one* quote sign in the beginning and on

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V wrote: > Quite often I need raw string literals for concatenating console commands. > I want to input them exactly as they are in python sources. > > There is r"" string, but it is obviously not enough because e.g. this: > s = r"ffmpeg -i "\\server-01\D\SER_Bigl.mpg" "

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 17:44, Mikhail V wrote: > Quite often I need raw string literals for concatenating console commands. > I want to input them exactly as they are in python sources. > > There is r"" string, but it is obviously not enough because e.g. this: > s = r"ffmpeg -i "\\server-01\D\SER_Bi

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 1:44 AM, Mikhail V wrote: > What I think: why there is no some built-in function, for example like: > s = raw("ffmpeg -i "\\server-01\D\SER_Bigl__"") > > which would just need *one* quote sign in the beginning and on the end. > Would it be useful, what do you think? I thin

Rawest raw string literals

2017-04-20 Thread Mikhail V
Quite often I need raw string literals for concatenating console commands. I want to input them exactly as they are in python sources. There is r"" string, but it is obviously not enough because e.g. this: s = r"ffmpeg -i "\\server-01\D\SER_Bigl.mpg" " is not valid. The closest I've found is tr