Stefan Ram wrote at 2021-9-24 14:53 GMT: >Steve Keller <keller.st...@gmx.de> writes: >>Why do some built-in Python functions feel so differently: > >|>>> s = set() >|>>> s.add( 1 ) >|>>> > > >|>>> l = [] >|>>> l.add( 1 ) > >| >|Traceback (most recent call last): >| File "<stdin>", line 1, in <module> >|AttributeError: 'list' object has no attribute 'add' >| >|>>> l.append( 1 )
A list is ordered. Therefore, it is important where in this order an element is added. Thus, for a list, `append` is a better name than `add` -- because it already tells us in the name where it adds the new element. A set is unordered. Therefore, the name `append` does not make sense for a set. -- Dieter -- https://mail.python.org/mailman/listinfo/python-list