On Mar 8, 1:49 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Fri, 07 Mar 2008 09:39:05 -0200, <[EMAIL PROTECTED]>
> escribi�:
>
> > Executive summary : What idiom do you use for resetting a list ?
> >lst = |] # (1)
> >lst[:] = [] # (2)
> >del lst[:] # (3)
>
> (3) if I wan
En Fri, 07 Mar 2008 09:39:05 -0200, <[EMAIL PROTECTED]>
escribi�:
> Executive summary : What idiom do you use for resetting a list ?
>lst = |] # (1)
>lst[:] = [] # (2)
>del lst[:] # (3)
(3) if I want to keep the same list else (1)
An example when (1) is desirable:
# generate
(second try with an enhanced version)
Executive summary : What idiom do you use for resetting a list ?
lst = |] # (1)
lst[:] = [] # (2)
del lst[:] # (3)
Consider the following code :
#!/usr/bin/env python
# -*- coding: latin_1 -*-
"""
container.py how to clear a container
"""
c
Consider the following code :
#!/usr/bin/env python
# -*- coding: latin_1 -*-
"""
container.py how to clear a container
"""
class Container(object):
def __init__(self):
self.elts = {}
self.parts = []
def clear(self):
self.elts.clear() # for a dictionary it's cl