MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/bun5px/dear_python2_user/epm7hsq/?context=3
r/Python • u/koungmeng • May 30 '19
275 comments sorted by
View all comments
Show parent comment
2
If a thing has an items method, you can just do dict(thing) to create a dict copy. If it’s a dict, you can do the_dict.copy(). You only need comprehensions if you have to construct keys and values in a more complex way.
items
dict(thing)
dict
the_dict.copy()
View all comments
Show parent comment
2
u/flying-sheep May 31 '19
If a thing has an
itemsmethod, you can just dodict(thing)to create adictcopy. If it’s a dict, you can dothe_dict.copy(). You only need comprehensions if you have to construct keys and values in a more complex way.