PythonにC++のconstみたいな、Javaのfinalみたいな修飾子を追加する…
パッチを書きました。
Python 2.6.5 (r265:79063, 魔改造, May 2 2010, 17:41:13) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def a(): ... readonly a = b = 3 ... a = 3 ... File "<stdin>", line 3 SyntaxError: variable 'a' is read-only >>> def a(): ... x = 3 ... readonly x = 3 ... File "<stdin>", line 3 SyntaxError: name 'x' is assigned to before readonly declaration >>> def a(): ... print x ... readonly x = 3 ... File "<stdin>", line 3 SyntaxError: name 'x' is used prior to readonly declaration
こんな感じで。どうでしょう。