Python Forum
choosing keyword argument names - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: choosing keyword argument names (/thread-42083.html)



choosing keyword argument names - Skaperen - May-06-2024

keyword argument names are going to be part of an API a (possible set of) function(s) will have. it would be good to choose a name that has some meaning to the programmer/coder using such an API. i have some names i am trying to come up with for my wait_{any,all}_path{,s}_to_exist() functions and others like these.

1. an argument to specify a maximum wait time, such that if such a time is reached without the condition being met, the function returns some code or raises some exception. it could specify an absolute time or the equivalent of a sleep time to indicate when to give up waiting for the condition. giving 0 means "forever". i have used the name "maxwait=" to give the delta time to when to give up. i have used a default value of 86400 seconds (1 day) for this.

2. an argument to specify the incremental times between each check of the condition, for functions that must have program logic regularly check the condition. i have used the name "step=" for this. i have used a default value of 0.25 seconds for this. i was thinking of changing the name to "blip=".

should i used different names, semantics, defaults for these?


RE: choosing keyword argument names - Gribouillis - May-07-2024

For point 1. the least surprise keyword is "timeout=", immediately understandable by every programmer. Even better if it raises an exception named TimeoutError.

For point 2. you could consider "every=" or "period=" or "interval=" perhaps, which are more explicit than "blip=".