serhii.net

In the middle of the desert you can say anything you want

22 Jun 2022

Python unpacking operator to get list of dictionary keys from dict_keys

The * operator works to get a list from dictionary keys!

  • my_dict.keys() returns a dict_keys object.
  • [*my_dict.keys()] returns the keys as list of str
    • list(..) would do the same but in a more readable way :)

Anyway filling this under “cool stuff I won’t ever use”

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus