pep 8 constants

Steve Holden steve at holdenweb.com
Thu Jan 22 22:06:17 EST 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
>> 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 ...
> 
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.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list