add comment on _spec
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Apr 2019 22:46:30 +0000 (23:46 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Apr 2019 22:46:30 +0000 (23:46 +0100)
src/add/stageapi.py

index eb90315c7fcc70518839ed95403ad2a1831bec91..dd969ae4ab3fc76d0404e9b7abd41c7c9cfae78d 100644 (file)
@@ -80,6 +80,13 @@ import nmoperator
 
 
 def _spec(fn, name=None):
+    """ useful function that determines if "fn" has an argument "name".
+        if so, fn(name) is called otherwise fn() is called.
+
+        means that ispec and ospec can be declared with *or without*
+        a name argument.  normally it would be necessary to have
+        "ispec(name=None)" to achieve the same effect.
+    """
     if name is None:
         return fn()
     varnames = dict(inspect.getmembers(fn.__code__))['co_varnames']