Conceptual
Login

Use Context Objects to Manage Many Function Arguments in Python

The context object pattern groups related values (configuration, runtime information, shared dependencies) into a single object that is passed through function calls, so that many separate arguments are replaced by one parameter. It addresses long parameter lists in software design, but trades fewer arguments for greater coupling, since every function receiving the context can depend on everything it holds. The guiding rule is to pass the context only at high levels of the call hierarchy and give low-level functions only the narrow inputs they actually need.