Py2.3: Feedback on Sets
adalke at mindspring.com
Thu Aug 14 02:24:44 CEST 2003
> Also, I'd like to see "iterable must be <some type spec>",
> though this is a general flaw in the Python doc and is perhaps
> biased by my C/C++ background where you'd never dream
> of doing a reference manual without explicitly indicating the
> types of every parameter.
Python uses what is sometimes called "duck typing" (meaning,
if it quacks like a duck...). Lots of objects are iterable - strings,
lists, sets, dict (keys), and user-defined classes. Since you
prefer C++, think of Python more akin to templates. Templates
expect the objects templated on to have certain properties (can
be "+"ed, can be deferenced, has a method named "xyz") and
not that they have given types.
> Personally, I have hard time imagining where I'd want
> [remove]. If I really cared, I could check beforehand, so I think
> I'd just always use discard.
I'm the other way around. I find it hard to imagine where
I would call discard. If I want to remove an element from a
set then I want to know right away if that element isn't there.
It's been handy for tracking down bugs in my code.
> engineering_management = engineers & programmers
Actually, I don't like that example because there is too
much text to read through to see the actual symbols used.
> PS I suppose I should mention my strongest pet peeve
> with the Python documentation, which is the practice of
> putting the member functions on a different page than
> the class overview. But that's not your issue, either.
And I confess that I like to see everything on one page
and not split up between several pages. That way I can
use my browser's search facility.
dalke at dalkescientific.com
More information about the Python-list