No, but you can achieve the same thing by doing this
record = {i: locals()[i] for i in ('id', 'name', 'email')}
(credits python variables as keys to dict )
but I wouldn’t do it, because it compromises readability and makes static checkers unable to find the undefined -name error.
Your example entered directly in python is the same as installed and is not a dictionary
{id, name, email} == set((id, name, email))
source share