Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
d0mine
on Nov 6, 2011
|
parent
|
context
|
favorite
| on:
Python: copying a list the right way
You can't say just looking at b[:] that its creates a copy unless you know its type e.g., if `b` is a numpy array then it doesn't copy the data and by changing b[i] you change a[i].
list(a), copy.copy(a) are more explicit.
Consider applying for YC's Fall 2026 batch!
Applications
are open till July 27.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
list(a), copy.copy(a) are more explicit.