Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have the following function:
def myfunc(str): x = str # i need to copy str into x , not but ref
I tesed copy Module but it didn't work.
copy Module
My question is, How i copy instead of by ref str into x?
copy
by ref
TypeError: 'str' object does not support item assignment
str
Since strings are immutable, there's no real difference between "by value" and "by reference" in your specific case.
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
copy"didn't work" what do you mean?TypeError: 'str' object does not support item assignmentstr, that might be part of your problem.