Hobs <hobsonl...@gmail.com> added the comment:
Not a bug. If you use quotes inside an f-string (or any other kind of string) they need to be escaped. --Hobson On Wed, Oct 23, 2019 at 12:09 PM Ying Wang <rep...@bugs.python.org> wrote: > > New submission from Ying Wang <yingw787.perso...@gmail.com>: > > Hey, > > I encountered an interesting bug when trying to do string parsing using > f-strings. I am currently under the impression that within the curly braces > is any expression that can be successfully evaluated in a REPL. Here's the > error: > > ```bash > yingw787@yingw787-Oryx-Pro:~/src/gpudb-dev-v6.2.0/kio/kio/tests/regression/_data/csv$ > python > Python 3.7.5 (default, Oct 15 2019, 21:38:37) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> blah = '"hi"' > >>> blah > '"hi"' > >>> f'{blah.strip('"')}' > File "<stdin>", line 1 > f'{blah.strip('"')}' > ^ > SyntaxError: EOL while scanning string literal > >>> '{0}'.format(blah.strip('"')) > 'hi' > >>> > ``` > > I can use '.format()' for now, but it might be nice to align f-string expr > behavior w/ .format(). Please let me know if you need more reproduction > steps, or if you need a helping hand :) > > Thanks > Ying > > ---------- > components: Interpreter Core > messages: 355254 > nosy: yingw787 > priority: normal > severity: normal > status: open > title: [3.7.5 x86_64 Linux] f-string parsing results in EOL > type: behavior > versions: Python 3.7 > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue38568> > _______________________________________ > _______________________________________________ > New-bugs-announce mailing list > new-bugs-annou...@python.org > https://mail.python.org/mailman/listinfo/new-bugs-announce > ---------- nosy: +Hobson.Lane _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38568> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com