[Tutor] dict vs several variables?

Peter Otten __peter__ at web.de
Fri Feb 17 13:11:46 CET 2012


Leam Hall wrote:

> I'm building a program that uses one of my own modules for a bunch of
> formula defs and another module for the tkinter GUI stuff. There are
> half a dozen input variables and about the same in calculated variables.
> Is it better/cleaner to just build a global dict and have everything go
> into it or pass multiple arguments to each function and have it return
> the calculated value?

The latter. It makes the dependencies explicit to a reader of the function, 
it simplifies unit tests, allows it to reuse functions in a different 
context, and it is more likely to work in a multi-threaded environment.



More information about the Tutor mailing list