Aug-01-2019, 12:16 AM
many of my functions accept many keyword arguments like:
they then have code to pop off the known keywords like:
then they check to see if any keywords are leftover like:
is it possible to output a multi-line message, one line for each keyword in this example, in the raised exception? i would also like to check the arguments, too, and combine messages related to this, too.
1 2 |
def callme( * args, * * opts): ... |
1 2 3 4 |
def callme( * args, * * opts): foo = opts.pop( 'foo' ,default_foo) bar = opts.pop( 'bar' ,default_bar) ... |
1 2 3 4 5 6 |
def callme( * args, * * opts): foo = opts.pop( 'foo' ,default_foo) bar = opts.pop( 'bar' ,default_bar) if opts: raise ValueError( f 'unknown keywords: {", ".join(x for x in opts.keys())}' ) ... |
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.