Python Forum
choosing keyword argument names
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
choosing keyword argument names
#1
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?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
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=".
Skaperen likes this post
« We can solve any problem by introducing an extra level of indirection »
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Query on choosing Python 3.8.6 version sureshnagarajan 0 1,841 Feb-16-2021, 05:30 AM
Last Post: sureshnagarajan
  function/method keyword argument alias Skaperen 1 3,187 Dec-01-2019, 03:56 AM
Last Post: Gribouillis
  Lost in choosing how to make an graphic interface TheGuyUnknown 3 2,732 Jul-01-2019, 02:08 AM
Last Post: metulburr
  [beginner] Choosing the right tool for a web-based GUI johsmi96 2 2,335 May-08-2019, 06:50 AM
Last Post: johsmi96

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020