Programming Idiomatic Code

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Jul 3 23:14:28 EDT 2007


Nathan Harmston a écrit :
>> > Using a module global for this kind of data is usually a bad idea
>> > (except eventually for run-once throw-away scripts, and even then...)
>> >
>> > Why is this a bad idea?
>>
>> Don't you have any idea ?
> 
> Not really.....problem with access, using unneeded memory... I
> grasping at straws here...

It makes generate_cound needlessly dependent on this global. It makes 
code harder to read. It makes code harder to test. It makes code harder 
to maintain. It makes code harder to reuse.

Ok, I understand this is probably not going to be a problem in this 
particular case. But you asked how idiomatic your code was, and using 
globals where not necessary is not pythonic.



More information about the Python-list mailing list