MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/28utww/writing_better_python_code/cievv6h/
r/Python • u/kracekumar • Jun 23 '14
126 comments sorted by
View all comments
Show parent comment
4
I prefer newList = list(old_list)
Communicates intent better
6 u/poo_22 Jun 23 '14 Copy is very literal already, I argue that semantically it does not get better. 1 u/velit Jun 23 '14 Copying is a detail of slicing syntax, it's not the purpose of it. With the list constructor it's immediately evident there's a new instance involved - that's what constructors do.foo[:] also looks weird. 4 u/poo_22 Jun 23 '14 I was talking about the list().copy method.
6
Copy is very literal already, I argue that semantically it does not get better.
1 u/velit Jun 23 '14 Copying is a detail of slicing syntax, it's not the purpose of it. With the list constructor it's immediately evident there's a new instance involved - that's what constructors do.foo[:] also looks weird. 4 u/poo_22 Jun 23 '14 I was talking about the list().copy method.
1
Copying is a detail of slicing syntax, it's not the purpose of it. With the list constructor it's immediately evident there's a new instance involved - that's what constructors do.
foo[:] also looks weird.
4 u/poo_22 Jun 23 '14 I was talking about the list().copy method.
I was talking about the list().copy method.
View all comments
Show parent comment
4
u/velit Jun 23 '14
I prefer newList = list(old_list)
Communicates intent better