Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am urbanonymous on github.
  • I am urbanon (https://keybase.io/urbanon) on keybase.
  • I have a public key ASAmSU1knADHuBmFLiKsUZVG0PaX8-kKjXAoIz9aMngV6Ao

To claim this, I am signing this object:

@urbanonymous
urbanonymous / check_one_arg_true.py
Created June 17, 2019 18:29
Checks that you only pass one argument to a full keyword optional arguments method
import inspect
def task(id_a=False, id_b=False, name=False, email=False, phone=False):
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
if len([arg for arg in args if values[arg]]) != 1: # Checks that you only pass one argument
raise ValueError("Need only one argument")