Can "None" be Reassigned in Python?

Starting with Python 2.4+, None cannot be reassigned:

# Python 2.4+
# SyntaxError: cannot assign to None
None = 'foo'

This guarantees that:

  • It is truly a constant, and;
  • All None references are always the same.

Please note that in versions of Python prior to 2.4, it is possible to reassign None.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.