Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-12 Thread Jach Feng
moi 在 2022年12月12日 星期一下午5:38:50 [UTC+8] 的信中寫道: > >>> ast.literal_eval("r'\x7a'") == ast.literal_eval("r'z'") > True > >>> ast.literal_eval("r'\xe0'") == ast.literal_eval("r'à'") > True > >>> ast.literal_eval("r'\x9c'") == ast.literal_eval("r'œ'") > False > > - > > > >>>

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Jach Feng
gt; - > - length 3 > 13 32 10 > From: Python-list on > behalf of Jach Feng > Date: Thursday, December 8, 2022 at 9:31 PM > To: pytho...@python.org > Subject: Re: How to convert a raw string r'xdd' to 'xdd' more gracefully? > *** Attention: This is an external email. Use cau

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Jach Feng
moi 在 2022年12月9日 星期五晚上11:41:20 [UTC+8] 的信中寫道: > PS C:\humour> py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z > cp1252 > a > b c > €uro > z > > PS C:\humour> $a = py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z > cp1252 > > PS C:\humour> licp($a) > a U+0061 > b

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Weatherby,Gerard
: print(f'{ord(c)} ',end='') print() Using bash on Linux: ./cl.py '^M ' Input - - length 3 13 32 10 From: Python-list on behalf of Jach Feng Date: Thursday, December 8, 2022 at 9:31 PM To: python-list@python.org Subject: Re: How to convert a raw string r'xdd' to 'xdd' more gracefully

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Jach Feng
Jach Feng 在 2022年12月7日 星期三上午10:23:20 [UTC+8] 的信中寫道: > s0 = r'\x0a' > At this moment it was done by > > def to1byte(matchobj): > return chr(int('0x' + matchobj.group(1), 16)) > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) > > But, is it that difficult on doing this simple thing? >

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Jach Feng
Jach Feng 在 2022年12月7日 星期三上午10:23:20 [UTC+8] 的信中寫道: > s0 = r'\x0a' > At this moment it was done by > > def to1byte(matchobj): > return chr(int('0x' + matchobj.group(1), 16)) > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) > > But, is it that difficult on doing this simple thing? >

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Peter Otten
On 08/12/2022 02:17, Jach Feng wrote: Peter Otten 在 2022年12月8日 星期四清晨5:17:59 [UTC+8] 的信中寫道: On 07/12/2022 03:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0)

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Thomas Passin
The original post started out with r'\x0a' but then talked about '\xdd'. I assumed that there was a pattern here, a raw string containing "\x" and two more characters, and made a suggestion for converting any string with that pattern. But the OP was very unclear what the task reall

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Weatherby,Gerard
return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) exam(s0) exam(s1) --- examine \x0a 92 \ 120 x 48 0 97 a examine 10 From: Python-list on behalf of Jach Feng Date: Wednesday, December 7, 2022 at 9:27 PM To: python-list@python.org Subject: Re: How to conver

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Jach Feng
Peter Otten 在 2022年12月8日 星期四清晨5:17:59 [UTC+8] 的信中寫道: > On 07/12/2022 03:23, Jach Feng wrote: > > s0 = r'\x0a' > > At this moment it was done by > > > > def to1byte(matchobj): > > return chr(int('0x' + matchobj.group(1), 16)) > > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) > > > >

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Jach Feng
Roel Schroeven 在 2022年12月7日 星期三下午4:42:48 [UTC+8] 的信中寫道: > Op 7/12/2022 om 4:37 schreef Jach Feng: > > MRAB 在 2022年12月7日 星期三上午11:04:43 [UTC+8] 的信中寫道: > > > On 2022-12-07 02:23, Jach Feng wrote: > > > > s0 = r'\x0a' > > > > At this moment it was done by > > > > > > > > def to1byte(matchobj): >

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Peter Otten
On 07/12/2022 03:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? >>> import codecs

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Jach Feng
Thomas Passin 在 2022年12月7日 星期三中午12:51:32 [UTC+8] 的信中寫道: > On 12/6/2022 9:23 PM, Jach Feng wrote: > > s0 = r'\x0a' > > At this moment it was done by > > > > def to1byte(matchobj): > > return chr(int('0x' + matchobj.group(1), 16)) > > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) > >

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Roel Schroeven
Op 7/12/2022 om 4:37 schreef Jach Feng: MRAB 在 2022年12月7日 星期三上午11:04:43 [UTC+8] 的信中寫道: > On 2022-12-07 02:23, Jach Feng wrote: > > s0 = r'\x0a' > > At this moment it was done by > > > > def to1byte(matchobj): > > return chr(int('0x' + matchobj.group(1), 16)) > > s1 =

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-06 Thread Thomas Passin
On 12/6/2022 9:23 PM, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? --Jach I'm not

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-06 Thread Jach Feng
MRAB 在 2022年12月7日 星期三上午11:04:43 [UTC+8] 的信中寫道: > On 2022-12-07 02:23, Jach Feng wrote: > > s0 = r'\x0a' > > At this moment it was done by > > > > def to1byte(matchobj): > > return chr(int('0x' + matchobj.group(1), 16)) > > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) > > > > But,

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-06 Thread MRAB
On 2022-12-07 02:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? You could try this:

How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-06 Thread Jach Feng
s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? --Jach -- https://mail.python.org/mailman/listinfo/python-list

[issue226510] Python 2.0: raw string, backslash in not handled correct

2022-04-10 Thread admin
Change by admin : -- github: None -> 33621 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue226510] Python 2.0: raw string, backslash in not handled correct

2022-04-10 Thread admin
Change by admin : -- github: None -> 33621 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-02 Thread Loris Bennett
Dennis Lee Bieber writes: > On Tue, 01 Mar 2022 08:35:05 +0100, Loris Bennett > declaimed the following: > >>Thanks for the various suggestions. The data I need to store is just a >>dict with maybe 3 or 4 keys and short string values probably of less >>than 32 characters each per event. The

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Loris Bennett
Robert Latest writes: > Loris Bennett wrote: >> Thanks for the various suggestions. The data I need to store is just a >> dict with maybe 3 or 4 keys and short string values probably of less >> than 32 characters each per event. The traffic on the DB is going to be >> very low, creating maybe

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Robert Latest via Python-list
Loris Bennett wrote: > Thanks for the various suggestions. The data I need to store is just a > dict with maybe 3 or 4 keys and short string values probably of less > than 32 characters each per event. The traffic on the DB is going to be > very low, creating maybe a dozen events a day, mainly

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Loris Bennett
Cameron Simpson writes: > On 28Feb2022 10:11, Loris Bennett wrote: >>I have an SQLAlchemy class for an event: >> >> class UserEvent(Base): >> __tablename__ = "user_events" >> >> id = Column('id', Integer, primary_key=True) >> date = Column('date', Date, nullable=False) >>

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Cameron Simpson
On 28Feb2022 10:11, Loris Bennett wrote: >I have an SQLAlchemy class for an event: > > class UserEvent(Base): > __tablename__ = "user_events" > > id = Column('id', Integer, primary_key=True) > date = Column('date', Date, nullable=False) > uid = Column('gid', String(64),

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Greg Ewing
On 1/03/22 6:13 am, Albert-Jan Roskam wrote: I think you need a BLOB.  https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.LargeBinary That won't help on its own, since you still need to choose a serialisation format to store in the blob. I'd be inclined to use

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Robert Latest via Python-list
Albert-Jan Roskam wrote: > The event may have arbitrary, but dict-like data associated with it, > which I want to add in the field 'info'.  This data never needs to be > modified, once the event has been inserted into the DB. > > What type should the info field have?  JSON,

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Albert-Jan Roskam
On Feb 28, 2022 10:11, Loris Bennett wrote: Hi, I have an SQLAlchemy class for an event:   class UserEvent(Base):   __tablename__ = "user_events"   id = Column('id', Integer, primary_key=True)   date = Column('date', Date, nullable=False)  

SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Loris Bennett
Hi, I have an SQLAlchemy class for an event: class UserEvent(Base): __tablename__ = "user_events" id = Column('id', Integer, primary_key=True) date = Column('date', Date, nullable=False) uid = Column('gid', String(64), ForeignKey('users.uid'), nullable=False)

[issue11479] Add discussion of trailing backslash in raw string to tutorial

2021-08-25 Thread Hanan Basheer
Change by Hanan Basheer <20b030...@iitb.ac.in>: -- nosy: +dancinglightning nosy_count: 10.0 -> 11.0 pull_requests: +26396 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/27949 ___ Python tracker

[issue11479] Add discussion of trailing backslash in raw string to tutorial

2021-08-20 Thread Irit Katriel
Irit Katriel added the comment: The patch needs to be converted into a github PR, and modified according to the feedback on this issue. -- keywords: +easy nosy: +iritkatriel versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 3.5

Re: Simple question - end a raw string with a single backslash ?

2021-04-24 Thread Peter J. Holzer
On 2020-10-19 06:24:18 -, Mladen Gogala via Python-list wrote: > On Mon, 19 Oct 2020 02:44:25 +, Stefan Ram wrote: > > Mladen Gogala writes: > >>In Perl, there are no classes. > > > > If there are no classes in Perl, then what does > > > > bless REF,CLASSNAME > > > > do? > >

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Eryk Sun
That's the first thing I thought of, though I would probably use a > non-space character to avoid convusion when reading: > > mystr = r'abc\_'[:-1] But it doesn't actually "end a raw string with a single backslash". The compiler could be optimized for slicing string literals,

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Grant Edwards
On 2020-10-19, Stephen Tucker wrote: > For a neatish way to get a string to end with a single backslash, how about >mystr = r"abc\ "[:-1] > (Note the space at the end of the rough-quoted string.) That's the first thing I thought of, though I would probably use a non-space character to avoid

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Stephen Tucker
Tony Flury via Python-list пише: > >> I am trying to write a simple expression to build a raw string that ends > >> in a single backslash. My understanding is that a raw string should > >> ignore attempts at escaping characters but I get this : > >>

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Antoon Pardon
Op 13/10/20 om 15:14 schreef Serhiy Storchaka: 13.10.20 11:52, Tony Flury via Python-list пише: I am trying to write a simple expression to build a raw string that ends in a single backslash. My understanding is that a raw string should ignore attempts at escaping characters but I get

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Chris Angelico
On Mon, Oct 19, 2020 at 5:26 PM Mladen Gogala via Python-list wrote: > bless \$ref will make the given reference a reference to the class. And > classes is Perl > are called "modules". However, Perl classes are not the classes in the real > sense. There > is no inheritance. You can have a

Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Mladen Gogala via Python-list
On Mon, 19 Oct 2020 02:44:25 +, Stefan Ram wrote: > Mladen Gogala writes: >>In Perl, there are no classes. > > If there are no classes in Perl, then what does > > bless REF,CLASSNAME > > do? bless \$ref will make the given reference a reference to the class. And classes is Perl

Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Michael Torrie
On 10/18/20 5:37 PM, Mladen Gogala via Python-list wrote: > On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote: > >> Python certainly is procedural. A script starts at the top and executes >> through to the bottom and ends, barring any flow control in the middle. >> Like Perl you can use

Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Mladen Gogala via Python-list
On Sun, 18 Oct 2020 12:19:18 -0600, Michael Torrie wrote: > Python certainly is procedural. A script starts at the top and executes > through to the bottom and ends, barring any flow control in the middle. > Like Perl you can use it in many different ways and paradigms including > OO if you

Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Michael Torrie
On 10/18/20 11:07 AM, Mladen Gogala via Python-list wrote: > The fundamental > difference between the two languages is that Perl is procedural while > Python is a fully OO language. Discussion of Perl vs Python necessarily > devolves into the discussion of procedural vs OO paradigms. Python

Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Mladen Gogala via Python-list
On Sun, 18 Oct 2020 16:13:16 +0200, Peter J. Holzer wrote: > > Ah, I see, that the sillyness of Perl's grammar-altering modules (which > let you write Perl in Latin (with proper declensions and conjugations, > of course) or Chinese) has found its way to Python > To tell the truth, I only

Re: Simple question - end a raw string with a single backslash ?

2020-10-18 Thread Peter J. Holzer
On 2020-10-17 21:03:26 -, Mladen Gogala via Python-list wrote: > On Thu, 15 Oct 2020 21:30:15 +, Stefan Ram wrote: > > Tony Flury writes: > >> >>> a = r'end' + chr(92) > > > > Or maybe, > > > > a = r''' > > end\ > > '''[ 1: -1 ] > > > > ? The first and the last line are messy, but

Re: Simple question - end a raw string with a single backslash ?

2020-10-17 Thread Mladen Gogala via Python-list
On Thu, 15 Oct 2020 21:30:15 +, Stefan Ram wrote: > Tony Flury writes: >> >>> a = r'end' + chr(92) > > Or maybe, > > a = r''' > end\ > '''[ 1: -1 ] > > ? The first and the last line are messy, but in the middle, > the intended string is clearly visible. You can use perl module for

Re: Simple question - end a raw string with a single backslash ?

2020-10-15 Thread Serhiy Storchaka
15.10.20 22:16, Roland Müller via Python-list пише: > I used the triple single quotes as delimiter: > s = r'''a single quote ', a double quote "''' s > > 'a single quote \', a double quote "' It does not help if the string contains both kinds of triple quotes You have to use

Re: Simple question - end a raw string with a single backslash ?

2020-10-15 Thread Roland Müller via Python-list
On 10/13/20 4:14 PM, Serhiy Storchaka wrote: 13.10.20 11:52, Tony Flury via Python-list пише: I am trying to write a simple expression to build a raw string that ends in a single backslash. My understanding is that a raw string should ignore attempts at escaping characters but I get

Re: Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Serhiy Storchaka
13.10.20 11:52, Tony Flury via Python-list пише: > I am trying to write a simple expression to build a raw string that ends > in a single backslash. My understanding is that a raw string should > ignore attempts at escaping characters but I get this : > >     >>> a = r'end

Re: Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Eryk Sun
On 10/13/20, Tony Flury via Python-list wrote: > I am trying to write a simple expression to build a raw string that ends > in a single backslash. My understanding is that a raw string should > ignore attempts at escaping characters but I get this : > > >>> a = r'end\

Simple question - end a raw string with a single backslash ?

2020-10-13 Thread Tony Flury via Python-list
I am trying to write a simple expression to build a raw string that ends in a single backslash. My understanding is that a raw string should ignore attempts at escaping characters but I get this : >>> a = r'end\'   File "", line 1     a = r'end\'    

Re: Raw string statement (proposal)

2018-05-27 Thread Dan Stromberg
On Thu, May 24, 2018 at 9:34 PM, Mikhail V wrote: > Hi. > I've put some thoughts together, and > need some feedback on this proposal. > Main question is: Is it convincing? > Is there any flaw? > My own opinion - there IS something to chase. > Still the justification for

Re: Raw string statement (proposal)

2018-05-26 Thread Mikhail V
On Sat, May 26, 2018 at 10:21 PM, Chris Angelico wrote: > > I'm done. Argue with brick walls for the rest of eternity if you like. I see you like me, but I can reciprocate your feelings. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list --

Re: Raw string statement (proposal)

2018-05-26 Thread Chris Angelico
EVERSE SOLIDUS? > I'll also ask you a question - > Which such non-text codes you may need to > generate C code? Python code? HTML code? What do you mean? >> And we've gone from a single string literal, which is an expression that >> can be used anywhere, to a statement th

Re: Raw string statement (proposal)

2018-05-26 Thread Mikhail V
tation. I'll also ask you a question - Which such non-text codes you may need to generate C code? Python code? HTML code? > > And we've gone from a single string literal, which is an expression that > can be used anywhere, to a statement that cannot be used in expressions. Ok show me your

Re: Raw string statement (proposal)

2018-05-26 Thread Steven D'Aprano
On Sat, 26 May 2018 18:22:15 +0300, Mikhail V wrote: >> Here is a string assigned to name `s` using Python's current syntax: >> >> s = "some\ncharacters\0abc\x01\ndef\uFF0A\nhere" >> >> How do you represent that assignment using your syntax? > > Hope its not mandatory to decipher your random

Re: Raw string statement (proposal)

2018-05-26 Thread Mikhail V
quot; > t = 'c' > > How do we write that piece of code using your syntax? That's too easy - maybe you can try it yourself? I am not trying to imply anything, but I don't see how this example can cause problems - just put the TQS in a block. >>> Would it then be possible to create a sour

Re: Raw string statement (proposal)

2018-05-26 Thread Steven D'Aprano
a source file PROG1.PY which contains such >> raw strings. >> >> Would it then be possible to create a source file PROG2.PY which >> contains PROG1.PY as a raw string? That is, without changing the text >> from PROG1.PY at all. > > Should be fine, with only diffe

Re: Raw string statement (proposal)

2018-05-25 Thread Mikhail V
question. > Another thing that might come up: suppose you do come up with a workable > scheme, and have a source file PROG1.PY which contains such raw strings. > > Would it then be possible to create a source file PROG2.PY which contains > PROG1.PY as a raw string? That is, wit

Re: Raw string statement (proposal)

2018-05-25 Thread bartc
e PROG1.PY which contains such raw strings. Would it then be possible to create a source file PROG2.PY which contains PROG1.PY as a raw string? That is, without changing the text from PROG1.PY at all. Here's one scheme I use in another language: print strinclude "file.txt" '

Raw string statement (proposal)

2018-05-24 Thread Mikhail V
Hi. I've put some thoughts together, and need some feedback on this proposal. Main question is: Is it convincing? Is there any flaw? My own opinion - there IS something to chase. Still the justification for such syntax is hard. Raw string statement -- Issue - Vast

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

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

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

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

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

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:

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

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

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

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

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 th

Re: Rawest raw string literals

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 7:13 AM, Mikhail V <mikhail...@gmail.com> 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

Re: Rawest raw string literals

2017-04-22 Thread Mikhail V
uot;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. > In *theory* one can define what characters can be part of the raw string. In Pyth

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

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

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

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

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. :-)

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

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

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

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

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

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 <mikhail...@gmail.com> wrote: On 20 April 2017 at 17:59, Grant Edwards <grant.b.edwa...@gmail.com> wrote: On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: Quite often I need raw string literals for con

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

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

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 --

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&qu

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: > On 20 April 2017 at 17:44, Mikhail V <mikhail...@gmail.com> wrote: >> Quite often I need raw string literals for concatenating console commands. >> I want to input them exactly as they are in python sources

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: > On 20 April 2017 at 17:59, Grant Edwards <grant.b.edwa...@gmail.com> wrote: >> On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: >>> Quite often I need raw string literals for concatenating consol

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
On Fri, Apr 21, 2017 at 2:16 AM, Mikhail V <mikhail...@gmail.com> wrote: > On 20 April 2017 at 17:59, Grant Edwards <grant.b.edwa...@gmail.com> wrote: >> On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: >>> Quite often I need raw string literals for concat

Re: Rawest raw string literals

2017-04-20 Thread Mikhail V
On 20 April 2017 at 17:59, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > On 2017-04-20, Mikhail V <mikhail...@gmail.com> wrote: >> Quite often I need raw string literals for concatenating console commands. >> I want to input them exactly as they are in pytho

Re: Rawest raw string literals

2017-04-20 Thread Chris Angelico
nd honestly, I hardly ever need this kind of thing - partly because I wouldn't call ffmpeg this way. I'd do it like this: cmd = ["ffmpeg", "-i", r"\\server-01\D\SER_Bigl.mpg"] with the separate arguments as, well, separate arguments. Far less need for double

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

Re: Rawest raw string literals

2017-04-20 Thread Grant Edwards
On 2017-04-20, Mikhail V <mikhail...@gmail.com> 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 Mikhail V
On 20 April 2017 at 17:44, Mikhail V <mikhail...@gmail.com> 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

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,

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

[issue27947] Trailing backslash in raw string format causes EOL

2016-09-02 Thread cfgbd
a double quote; r"\" is not a valid string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw literal cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backsl

[issue27947] Trailing backslash in raw string format causes EOL

2016-09-02 Thread Tim Peters
Changes by Tim Peters : -- resolution: -> not a bug stage: -> resolved status: open -> closed versions: +Python 3.2 -Python 3.4 ___ Python tracker

  1   2   3   >