pep 8 constants

Brian Allen Vanderburg II BrianVanderburg2 at aim.com
Thu Jan 22 15:55:10 EST 2009


bockman at virgilio.it 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>   
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:

@property
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