[Tutor] dict vs several variables?

leam hall leamhall at gmail.com
Fri Feb 17 14:04:53 CET 2012

Thanks Peter!

My concern with variables is that they have to be passed in specific
order to the function, and they may have to have their type set
multiple times so that you can perform the right functions on them. In
a dict you could set it on insert and not have to worry about it.



On 2/17/12, Peter Otten <__peter__ at web.de> wrote:
> 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.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Mind on a Mission <http://leamhall.blogspot.com/>

More information about the Tutor mailing list