In the python-ideas mailing list
http://mail.python.org/pipermail/python-ideas/2007-March/thread.html there
was a discussion about the fact that python has opeartors 'and', 'or' and
'not' (keywords of the language) but 'bool' is a type. Naturally we have
(not not x) == bool(x) # always True
If
Duncan Booth wrote :
> francois.petitjean at bureauveritas.com wrote:
>> After much head scrating and experimenting with dis.dis() I have found
>> that chaining comparisons (with is or ==) a == b == c in Python is
>> never a good idea. It is interpreted as
>> ( a == b ) and ( b == c)
>> Such a m
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
(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