python needs leaning stuff from other language
Luis Alberto Zarrabeitia Gomez
kyrie at uh.cu
Fri Apr 3 01:02:55 CEST 2009
Quoting Esmail <ebonak at hotmail.com>:
> Diez B. Roggisch wrote:
> > some_list[:] = 
> I agree that this is nice and clear,
Not very intuitive, though, until you learn the syntax.
(but, slice accessing and slice assignment are among the first few things one
learns about python anyway, and once you learn it, it seems more than natural)
> but as a relative newbie
> some_list = 
> be also acceptable (and pythonic?)?
Acceptable, it may not be (depending on the problem). And I would adventure that
if someone needs to clear a list instead of creating an empty one, its likely
that someone is facing one of those problems (i.e: clearing a list that you got
as a function argument, or playing with os.walk).
Facultad de Matemática y Computación, UH
Participe en Universidad 2010, del 8 al 12 de febrero de 2010
La Habana, Cuba
More information about the Python-list