MCPcopy Create free account
hub / github.com/longld/peda / string_repr

Function string_repr

lib/utils.py:863–879  ·  view source on GitHub ↗

Prints the repr of a string. Eliminates the leading 'b' in the repr in Python 3. Optionally can show or include quotes.

(text, show_quotes=True)

Source from the content-addressed store, hash-verified

861
862
863def string_repr(text, show_quotes=True):
864 """
865 Prints the repr of a string. Eliminates the leading 'b' in the repr in
866 Python 3.
867
868 Optionally can show or include quotes.
869 """
870 if six.PY3 and isinstance(text, six.binary_type):
871 # Skip leading 'b' at the beginning of repr
872 output = repr(text)[1:]
873 else:
874 output = repr(text)
875
876 if show_quotes:
877 return output
878 else:
879 return output[1:-1]

Callers 3

stringsMethod · 0.85
substrMethod · 0.85
format_reference_chainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected