5 odpowiedzi
+ 5
In Python you can't define constants like in other languages.
+ 5
There are no constants in Python, only workarounds if you truly feel that it is necessary. You can signal that a value is a constant by using all upper letters for the identifier.
For a workaround you can use @property (in classes). Here is a code explaining it a bit:
https://code.sololearn.com/cKcc6g3Q6max/#py
+ 3
The information is misleading.
In Python you have no real constants. They are just using capitals to *suggest* a constant.
A lot in Python follows this idea: Assuming the people stick to conventions and just *know* they shouldn't change a VALUE.
But you can.
+ 1
I don't know much HonFu but I have seen it in an article.
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/variables-constants-literals