I gather from answers like this that Python's built-in type set
has a number of useful class methods, such as set.intersection()
. Where are they documented? I haven't found them documented here, which seems to cover only the instance methods.
Here's an example demonstrating the existence of one of these class methods:
>>> set.intersection(set([1, 2, 3]), set([2, 3, 4]))
{2, 3}
>>> set.intersection([1, 2, 3], [2, 3, 4])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
>>> set([1, 2, 3, 4]).intersection([1, 2, 3], [2, 3, 4]) # same args, passed to instance method
{2, 3}
The documentation for the instance method says that it accepts any iterable as an argument, not just a set. The example above shows that the class method works differently.
It would be nice to know what arguments you are supposed to be able to pass to these functions without having to guess and test.