MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/4nd3lc/scientific_python_cheat_sheet/d43og03/?context=3
r/Python • u/Link2mypast • Jun 09 '16
62 comments sorted by
View all comments
5
Maybe add the [:] operator as a nice 'pythonic' way to copy a list. Example:
l = [1, 2, 3, 4, 5] k = l k[3] = 0 print(k[3] == l[3]) # True print(k[3], l[3]) # 0 0 l = [1, 2, 3, 4, 5] k = l[:] k[3] = 0 print(k[3] == l[3]) # False print(k[3], l[3]) # 0 4
3 u/flutefreak7 Jun 10 '16 Yeah, and a[::-1] to get the reverse of a numpy array. 1 u/Ogi010 Jun 10 '16 I like the .copy method (only works in Python 3)k = l.copy()
3
Yeah, and a[::-1] to get the reverse of a numpy array.
1
I like the .copy method (only works in Python 3)
k = l.copy()
5
u/datosh Jun 10 '16
Maybe add the [:] operator as a nice 'pythonic' way to copy a list. Example: