pep 8 constants

Albert Hopkins marduk at letterboxes.org
Wed Jan 14 11:17:14 EST 2009


On Wed, 2009-01-14 at 16:58 +1000, James Mills wrote:
[...]
> Still I would avoid using this idiom altogether
> and jsut stick with default values. For Example:
> 
> FOO = 1
> 
> def f(x=FOO):
>    ...
> 
> 
> Use this instead:
> 
> def f(x=1):
>    ...

That only works well when "1" is only used once, and as an argument to a
function. Once you find yourself outside of that special case then
anytime you want to change "1" to "2" then you're going to regret having
made that decision.





More information about the Python-list mailing list