Python Forum
is an f-sting not a literal?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is an f-sting not a literal?
#1
is an f-sting not a literal? it fails in ast.literal_eval():
Output:
lt2a/forums /home/forums 4> py Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> a='f"""hello Python forum"""' >>> b=ast.literal_eval(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.6/ast.py", line 85, in literal_eval return _convert(node_or_string) File "/usr/lib/python3.6/ast.py", line 84, in _convert raise ValueError('malformed node or string: ' + repr(node)) ValueError: malformed node or string: <_ast.JoinedStr object at 0x7f42dd9486a0> >>> a='"""hello Python forum"""' >>> b=ast.literal_eval(a) >>> b 'hello Python forum' >>> lt2a/forums /home/forums 5>
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
is an f-sting not a literal? - by Skaperen - May-20-2021, 10:52 PM
RE: is an f-sting not a literal? - by perfringo - May-21-2021, 06:10 AM
RE: is an f-sting not a literal? - by Gribouillis - May-21-2021, 06:28 AM
RE: is an f-sting not a literal? - by Skaperen - May-21-2021, 06:23 PM
RE: is an f-sting not a literal? - by Gribouillis - May-21-2021, 06:58 PM
RE: is an f-sting not a literal? - by Skaperen - May-23-2021, 11:09 PM
RE: is an f-sting not a literal? - by Gribouillis - May-24-2021, 08:47 AM
RE: is an f-sting not a literal? - by Skaperen - May-31-2021, 05:25 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020