The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python FAQ. Why are Python strings immutable? Video tutorial with examples
By Guest on 8th November 2022 01:39:36 AM | Syntax: PYTHON | Views: 194



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. Why are Python strings immutable?
  2. =================================
  3.  
  4. There are several advantages.
  5.  
  6. One is performance: knowing that a string is immutable means we can
  7. allocate space for it at creation time, and the storage requirements
  8. are fixed and unchanging.  This is also one of the reasons for the
  9. distinction between tuples and lists.
  10.  
  11. Another advantage is that strings in Python are considered as
  12. "elemental" as numbers.  No amount of activity will change the value 8
  13. to anything else, and in Python, no amount of activity will change the
  14. string "eight" to anything else.
  15.  
  16. Also see:
  17. Beginner Python Tutorial - Strings are Immutable
  18. https://www.youtube.com/watch?v=-ii2tXVqtc4
















Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.

Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.

See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license
  • Recent Pastes