constants
Jay O'Connor
joconnor at cybermesa.com
Sun Aug 25 16:05:01 EDT 2002
On Mon, 26 Aug 2002 01:49:30 +0700, David Garamond
<davegaramond at icqmail.com> wrote:
>does python support some sort of constant variables?
>
>in ruby, variables that begin with an uppercase letter is considered a
>constant. that is, once bound to a value, nobody can rebind it until the
>end of program execution (though it certainly does not prevent the bound
>object value to be changed):
>
>$ irb
>irb(main):001:0> A=1
>irb(main):002:0> A=2
>(irb):2: warning: already initialized constant A
>irb(main):003:0> B=[1,2,3]
>irb(main):006:0> B[1]=3
>irb(main):007:0> B
>[1, 3, 3]
Here's a liink to a recipe describing a technique for enforcing
constants in Python
http://www.onlamp.com/pub/a/python/2002/07/11/recipes.html
Jay O'Connor
joconnor at cybermesa.com
http://www.cybermesa.com/~joconnor
"God himself plays on the bass strings first, when he tunes the soul"
More information about the Python-list
mailing list