1 import mal_types
as types
4 return s
.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
6 def _pr_str(obj
, print_readably
=True):
9 return "(" + " ".join(map(lambda e
: _pr_str(e
,_r
), obj
)) + ")"
10 elif types
._vector
_Q
(obj
):
11 return "[" + " ".join(map(lambda e
: _pr_str(e
,_r
), obj
)) + "]"
12 elif types
._hash
_map
_Q
(obj
):
15 ret
.extend((_pr_str(k
), _pr_str(obj
[k
],_r
)))
16 return "{" + " ".join(ret
) + "}"
17 elif type(obj
) in types
.str_types
:
18 if len(obj
) > 0 and obj
[0] == types
._u('\u029e'):
21 return '"' + _escape(obj
) + '"'
24 elif types
._nil
_Q
(obj
):
26 elif types
._true
_Q
(obj
):
28 elif types
._false
_Q
(obj
):
30 elif types
._atom
_Q
(obj
):
31 return "(atom " + _pr_str(obj
.val
,_r
) + ")"