For dictionaries it'd even be more useful:
d = {
'first_name': 'Frances',
'last_name': 'Allen',
'email': '[email protected]'
}
fname, lname = d[['first_name', 'last_name']]
Why not do this?
import operator
first_last = operator.itemgetter("first_name", "last_name")
fname, lname = first_last(d)
https://docs.python.org/3.8/library/operator.html#operator.itemgetter
--
https://mail.python.org/mailman/listinfo/python-list
