Function Defaults - avoiding unneccerary combinations of arguments at input
Ivan Evstegneev
webmailgroups at gmail.com
Wed Mar 25 13:43:34 EDT 2015
Hello all ,
Just a little question about function's default arguments.
Let's say I have this function:
def my_fun(history=False, built=False, current=False, topo=None,
full=False, file=None):
if currnet and full:
do something_1
elif current and file:
do something_2
elif history and full and file:
do something_3
...... some code here..............
and so on...
I won't cover all the possibilities here (actually I don't use all of them
^_^).
The question is about avoiding the response for unnecessary combinations?
For instance, if user will call function this way:
>>>my_fun(current=True, full=True, topo='some str', file="some_file")
That will lead to function's misbehavior. As a particular case it will
choose "current and full" condition.
What is the common accepted way to deal with such unwanted situations?
Thanks a lot in advance,
Ivan.
More information about the Python-list
mailing list