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)
| 861 | |
| 862 | |
| 863 | def 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] |
no outgoing calls
no test coverage detected