Details the proper way to call a callable
Change-Id: I288822ed3aa8a755fc90fbf7940da043995cb719
This commit is contained in:
parent
b2f3b5c25b
commit
b1b8cb2bb8
20
HACKING.rst
20
HACKING.rst
@ -36,3 +36,23 @@ AssertEqual argument order
|
||||
--------------------------
|
||||
|
||||
assertEqual method's arguments should be in ('expected', 'actual') order.
|
||||
|
||||
|
||||
Properly Calling Callables
|
||||
--------------------------
|
||||
|
||||
Methods, functions and classes can specify optional parameters (with default
|
||||
values) using Python's keyword arg syntax. When providing a value to such a
|
||||
callable we prefer that the call also uses keyword arg syntax. For example::
|
||||
|
||||
def f(required, optional=None):
|
||||
pass
|
||||
|
||||
# GOOD
|
||||
f(0, optional=True)
|
||||
|
||||
# BAD
|
||||
f(0, True)
|
||||
|
||||
This gives us the flexibility to re-order arguments and more importantly
|
||||
to add new required arguments. It's also more explicit and easier to read.
|
||||
|
Loading…
Reference in New Issue
Block a user