Every line of 'python __str__' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
93 def py_str(py): 94 '''Turns a python value into a string of python code 95 representing that object''' 96 def maybe_str(s): 97 return s if isinstance(s, str) and '(' in s else repr(s) 98 99 if type(py) is dict: 100 return '{' + ', '.join( 101 [repr(k) + ': ' + maybe_str(py[k]) for k in py]) + '}' 102 if not isinstance(py, basestring): 103 return repr(py) 104 else: 105 return py