Apr-21-2020, 06:23 PM
(This post was last modified: Apr-21-2020, 06:23 PM by deanhystad.)
Has nothing to do with dictionaries. This does the same thing:
value = '\python'
value
'\\python'
I found this:
"The extra backslash is not actually added; it's just added by the repr() function to indicate that it's a literal backslash. The Python interpreter uses the repr() function (which calls __repr__() on the object) when the result of an expression needs to be printed:"
This makes sense. When you use print(str), python uses str.__str__(). I guess when you use print(dict) python uses __repr__ for the keys and values thinking that you are interested in the details.
I think it is time to write a nice short function that will print your directories. Maybe take a look at pprint or json.dumps.
value = '\python'
value
'\\python'
I found this:
"The extra backslash is not actually added; it's just added by the repr() function to indicate that it's a literal backslash. The Python interpreter uses the repr() function (which calls __repr__() on the object) when the result of an expression needs to be printed:"
This makes sense. When you use print(str), python uses str.__str__(). I guess when you use print(dict) python uses __repr__ for the keys and values thinking that you are interested in the details.
I think it is time to write a nice short function that will print your directories. Maybe take a look at pprint or json.dumps.