Procs
func pyrepr(s: openArray[char]; escape127: static[bool] = false): string
-
Python's repr but returns Nim's string.
nim's Escape Char feature can be enabled via -d:useNimCharEsc, in which 'e' (i.e.'x1B' in Nim) will be replaced by "\e"
Example:
# NOTE: string literal's `repr` is `system.repr`, as following. assert repr("\"") == "\"\\\"\"" # string literal of "\"" # use pyrepr for any StringLike and returns a PyStr assert pyrepr("\"") == "'\"'"
Source Edit