मैं वर्तमान में गोता में अजगर और मार्क तीर्थ के अध्याय 5.8 पढ़ रहा हूँ कहते हैं:पायथन में कोई भी मूल्य कैसे बदलें?
There are no constants in Python. Everything can be changed if you try hard enough. This fits with one of the core principles of Python: bad behavior should be discouraged but not banned. If you really want to change the value of None, you can do it, but don't come running to me when your code is impossible to debug.
मैं दुभाषिया में यह करने की कोशिश की
None = "bad"
मैं एक सिंटैक्स त्रुटि प्राप्त: कोई नहीं करने के लिए काम
जिज्ञासा से बाहर आप कैसे बदलते हैं कोई नहीं?
संपादित करें:
दिलचस्प बात यह है:
>>> import __builtin__
>>> __builtin__.None is None
True
>>> None
>>> None = "bad"
File "<stdin>", line 1
SyntaxError: assignment to None
>>> __builtin__.None = "bad"
File "<stdin>", line 1
SyntaxError: assignment to None
>>> setattr(__builtin__, "None", "bad")
>>> __builtin__.None
'bad'
>>> None
>>> __builtin__.None is None
False
>>> __builtin__.None = None
File "<stdin>", line 1
SyntaxError: assignment to None
इसके अलावा
>>> class Abc:
... def __init__(self):
... self.None = None
...
File "<stdin>", line 3
SyntaxError: assignment to None
>>> class Abc:
... def __init__(self):
... setattr(self,'None',None)
...
>>>
तो मुझे लगता है कि 'कोई नहीं =' बस किसी भी संदर्भ में काम नहीं करता है
मुझे लगता है कि 2.3 ने आपको एक सिंटेक्स चेतावनी दी है, fwiw। – perimosocordiae
उत्तर के लिए धन्यवाद, मुझे लगता है कि नए संस्करणों में अब थग्स के लिए कोई प्यार नहीं है। –
हालांकि आप 2.6 में अभी भी 'True = False' कर सकते हैं। और इसका प्रभाव आप चाहते हैं। – viraptor