Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raw string
#1
you are writing code (probably a function that can be used in a purpose-designed code generator program) that takes in data from a file and outputs code that is a Python string literal, with the proper quotes, that could be used anywhere a string literal is allowed to produce the entire contents of that file. your goals include readability for humans (like using \r instead of \015 for carriage return) and keeping both the whole result and the part between the quotes (whichever quotes are used) as short as possible (like using \r instead of \015 for carriage return) and and use single quotes unless something else meets the other goals better. how would your code output a file containing just one backslash character? would it output r'\' or '\\' ?
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
raw string - by Skaperen - Jan-10-2018, 02:43 AM
RE: raw string - by Gribouillis - Jan-10-2018, 08:48 PM
RE: raw string - by wavic - Jan-10-2018, 09:27 PM
RE: raw string - by Skaperen - Jan-11-2018, 04:58 AM
RE: raw string - by Gribouillis - Jan-11-2018, 06:56 AM
RE: raw string - by Skaperen - Jan-11-2018, 08:35 AM

Forum Jump:

User Panel Messages

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