Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
no tuple.copy()
#2
it's immutable. why would you need a copy? Reference is good enough.
there is no e.g. str.copy either :-)

Note that with [:] it's the same object (same id), not a copy

Python 3.9.4 (default, Apr  9 2021, 01:15:05) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> spam = (1, 2, 3)
>>> eggs = spam[:]
>>> id(spam)
139751983214912
>>> id(eggs)
139751983214912
>>> 
Skaperen likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
no tuple.copy() - by Skaperen - Apr-30-2022, 05:28 PM
RE: no tuple.copy() - by buran - May-04-2022, 04:16 AM
RE: no tuple.copy() - by ndc85430 - May-04-2022, 05:31 AM
RE: no tuple.copy() - by buran - May-04-2022, 08:29 AM
RE: no tuple.copy() - by Skaperen - May-04-2022, 04:20 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020