I am trying to skip parameters while calling a function. Could you please help me how to do this?
Example:
I have to call below function which is having 3 parameters:
send_mail(audit_df, LOG_FILE, Duration)
I have to call above function to skip 1st and 3rd parameters. How can i do this?
You can setup default values for the parameters. I don't know what works for you, so I just set them to None
.
def send_mail(audit_df=None, log_file=None, duration=None):
do all the things
when calling
send_mail(log_file="myfile")
For a little light reading see the Function definitions section of the docs.
You can place "None" in place of the parameter.
This is going to make python assume that it is Nothing and will do nothing.
This can be done in two ways using
See the answer below for details
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.