I guess that this allows me to type help(list) and figure it out, but I would have done that anyway to identify an operator.
Clearly the answer is a .clone() or .copy() method...
I guess that this allows me to type help(list) and figure it out, but I would have done that anyway to identify an operator.
Clearly the answer is a .clone() or .copy() method...
I honestly have never seen someone do foo[:] just to copy a list, this is all news to me.
if you want Python to smell like Java or Ruby. :->
Seems to disagree with you.
What I'm saying is, there's no copy or clone or dup method built into Python's base object, as there is in Ruby. And Python programmers are not instructed to define a clone method for a class, as in Java. A __copy__ or __deepcopy__, okay, but not copy or deepcopy.
Hence, in Python you just don't see foo.clone() or foo.dup() or foo.copy() or foo.deepcopy(). Instead, you see copy.copy(foo) or copy.deepcopy(foo). Pythonic code often looks different than Ruby or Java, looks more stand-alone function-y than instance method-y.