Class or Dictionary?

Ethan Furman ethan at stoneleaf.us
Fri Feb 11 13:47:45 EST 2011


Andrea Crotti wrote:
> On Feb 11, 3:56 pm, Martin De Kauwe <mdeka... at gmail.com> wrote:
>> Hi,
>>
>> I have a series of parameter values which i need to pass throughout my
>> code (>100), in C I would use a structure for example. However in
>> python it is not clear to me if it would be better to use a dictionary
>> or build a class object? Personally I think accessing the values is
>> neater (visually) with an object rather than a dictionary, e.g.
>>
>> x = params['price_of_cats'] * params['price_of_elephants']
>>
>> vs.
>>
>> x = params.price_of_cats * params.price_of_elephants
> 
> Visually neater is not really a good parameter to judge.

I strongly disagree.  Code readability is one of the most important issues.

~Ethan~



More information about the Python-list mailing list