use set notation for repr of dict_keys?

Wolfgang Stöcher wolfgang at stoecher.com
Sat Feb 20 02:25:29 EST 2021


Having a dict like
   d = {'one': 1, 'two': 2}
the representation of its keys
   repr(d.keys())
gives
   "dict_keys(['one', 'two'])"

But since the keys are unique, wouldn't a representation using the set  
notation
be more intuitive, i.e. what about changing the output of  
dict_keys.__repr__ to
	"dict_keys({'one', 'two'})"
(using curly braces instead of brackets)

Wolfgang



More information about the Python-list mailing list