pep 8 constants

Brian Allen Vanderburg II BrianVanderburg2 at
Thu Jan 22 21:55:10 CET 2009

bockman at wrote:
> Constants would be a nice addition in python, sure enough.
> But I'm not sure that this can be done without a run-time check every time
> the constant is used, and python is already slow enough. Maybe a check
> that is disabled when running with optimizing flags ?
> But I'm sure this discussion has been already made and the FINAL WORD has
> been already spoken.
> Ciao
> ----
> FB
> --
One idea to make constants possible would be to extend properties to be 
able to exist at the module level as well as the class level:

def pi():
    return 3.14159.....

print(pi) # prints 3.14159....
pi=32 # Raise an error Cannot set attribute ...

Brian Vanderburg II

More information about the Python-list mailing list