pep 8 constants
steve at holdenweb.com
Fri Jan 23 04:06:17 CET 2009
Brian Allen Vanderburg II wrote:
> 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
>> 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.
> 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 ...
I don't understand why this would print 3.14159 ... instead of <function
__math__.pi>, or whatever.
property would clearly have to do something very different in module
scope in order to make this work.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list