declare a constant in Python?

B

beliavsky

I wish one could declare a constant in Python, analogous to 'const int
i=1;' in C++. Is there a way to get this effect?
 
D

Dave Brueck

I wish one could declare a constant in Python, analogous to 'const int
i=1;' in C++. Is there a way to get this effect?

With a bit of work, yes - Google will turn up some recipes for it.

It's basically never worth the effort because in practice it offers no advantage
over just a naming convention (i.e. nobody accidentally rebinds their values, so
doing that extra work doesn't provide any practical benefit).

-Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top