I have been reading a few posts about switch replacements such as:
- What is the Python equivalent for a case/switch statement?
- Replacements for switch statement in Python?
But none of them seem to fit my need.
What I really want is something like this
def f(x):
switch(x):
case 'pk':
return User.objects.get(pk=x)
case: 'email':
return User.objects.get(email=x)
Is there an easy way for this to be done?