101
101
if getattr(thing, 'name', None) is None
107
``**kwargs`` in the prototype of a function should be used sparingly.
108
It can be good on higher-order functions that decorate other functions,
109
such as ``addCleanup`` or ``assertRaises``, or on functions that take only
110
(or almost only) kwargs, where any kwargs can be passed.
112
Otherwise, be careful: if the parameters to a function are a bit complex
113
and might vary over time (e.g. the ``commit`` API) then we prefer to pass an
114
object rather than a bag of positional and/or keyword args. If you have
115
an arbitrary set of keys and values that are different with each use (e.g.
116
string interpolation inputs) then again that should not be mixed in with
117
the regular positional/keyword args, it seems like a different category of
121
Imitating standard objects
122
==========================
124
Don't provide methods that imitate built-in classes (eg ``__in__``,
125
``__call__``, ``__int__``, ``__getitem__``) unless the class you're
126
implementing really does act like the builtin class, in semantics and
129
For example, old code lets you say ``file_id in inv`` but we no longer
130
consider this good style. Instead, say more explicitly
131
``inv.has_id(file_id)``.
133
``__repr__``, ``__cmp__``, ``__str__`` are usually fine.