How do I create a constant in Python?
Is there a way to declare a constant in Python? In Java we can create constant values in this manner:<!-- language: lang-java --> public static final String CONST_NAME = "Name";What is the equivalent of the above Java constant declaration in Python?
Utkarsh S.
answered 06/14/19
Math/Bio/Python Tutor. Well versed and practiced!
You cannot create a constant in python but you could put two _ before the name to make it private (Not truly private in the java sense of private).
Still looking for help? Get the right answer, fast.
OR
Find an Online Tutor Now
Choose an expert and meet online.
No packages or subscriptions, pay only for the time you need.
¢
€
£
¥
‰
µ
·
•
§
¶
ß
‹
›
«
»
<
>
≤
≥
–
—
¯
‾
¤
¦
¨
¡
¿
ˆ
˜
°
−
±
÷
⁄
×
ƒ
∫
∑
∞
√
∼
≅
≈
≠
≡
∈
∉
∋
∏
∧
∨
¬
∩
∪
∂
∀
∃
∅
∇
∗
∝
∠
´
¸
ª
º
†
‡
À
Á
Â
Ã
Ä
Å
Æ
Ç
È
É
Ê
Ë
Ì
Í
Î
Ï
Ð
Ñ
Ò
Ó
Ô
Õ
Ö
Ø
Œ
Š
Ù
Ú
Û
Ü
Ý
Ÿ
Þ
à
á
â
ã
ä
å
æ
ç
è
é
ê
ë
ì
í
î
ï
ð
ñ
ò
ó
ô
õ
ö
ø
œ
š
ù
ú
û
ü
ý
þ
ÿ
Α
Β
Γ
Δ
Ε
Ζ
Η
Θ
Ι
Κ
Λ
Μ
Ν
Ξ
Ο
Π
Ρ
Σ
Τ
Υ
Φ
Χ
Ψ
Ω
α
β
γ
δ
ε
ζ
η
θ
ι
κ
λ
μ
ν
ξ
ο
π
ρ
ς
σ
τ
υ
φ
χ
ψ
ω
ℵ
ϖ
ℜ
ϒ
℘
ℑ
←
↑
→
↓
↔
↵
⇐
⇑
⇒
⇓
⇔
∴
⊂
⊃
⊄
⊆
⊇
⊕
⊗
⊥
⋅
⌈
⌉
⌊
⌋
〈
〉
◊