๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_ref_set.asp
Python Set Methods
Python has a set of built-in methods that you can use on sets.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ c-api โ€บ set.html
Set Objects โ€” Python 3.14.3 documentation
This section details the public API for set and frozenset objects. Any functionality not listed below is best accessed using either the abstract object protocol (including PyObject_CallMethod(), Py...
๐ŸŒ
docs.python.org
docs.python.org โ€บ 3 โ€บ library โ€บ sets.html
Built-in Types โ€” Python 3.7.3 documentation
The reverse() method modifies the sequence in place for economy of space when reversing a large sequence. To remind users that it operates by side effect, it does not return the reversed sequence. clear() and copy() are included for consistency with the interfaces of mutable containers that donโ€™t support slicing operations (such as dict and set...
๐ŸŒ
Python Reference
python-reference.readthedocs.io โ€บ en โ€บ latest โ€บ docs โ€บ sets
set โ€” Python Reference (The Right Way) 0.1 documentation
Sets are mutable unordered collections of unique elements. Common uses include membership testing, removing duplicates from a sequence, and computing standard math operations on sets such as intersection, union, difference, and symmetric difference ยท Sets do not record element position or ...
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ datastructures.html
5. Data Structures โ€” Python 3.14.3 documentation
This chapter describes some things youโ€™ve learned about already in more detail, and adds some new things as well. More on Lists: The list data type has some more methods. Here are all of the method...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ set
Python Set Methods | Programiz
Become a certified Python programmer. Try Programiz PRO! ... A set is an unordered collection of items. Set items are unique and immutable. In this reference page, you will find all the methods that a set object can use.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_sets.asp
Python Sets
Python Sets Access Set Items Add Set Items Remove Set Items Loop Sets Join Sets Frozenset Set Methods Set Exercises Code Challenge Python Dictionaries
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ home โ€บ python โ€บ python set methods
Python Set Methods
February 21, 2009 - You can view all available methods for sets, using the Python dir() function to list all properties and functions related to the set class. Additionally, the help() function provides detailed documentation for each method.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-set-methods
Python Set Methods - GeeksforGeeks
November 12, 2021 - Python set isdisjoint() function check whether the two sets are disjoint or not, if it is disjoint then it returns True otherwise it will return False. Two sets are said to be disjoint when their intersection is null.ร‚ Python set isdisjoint() Method Syntax: Syntax: set1.isdisjoint(set2) Parameters:
Find elsewhere
๐ŸŒ
Python Tips
book.pythontips.com โ€บ en โ€บ latest โ€บ set_-_data_structure.html
5. set Data Structure โ€” Python Tips 0.1 documentation
valid = set(['yellow', 'red', 'blue', 'green', 'black']) input_set = set(['red', 'brown']) print(input_set.difference(valid)) # Output: set(['brown']) ... There are a few other methods as well. I would recommend visiting the official documentation and giving it a quick read.
๐ŸŒ
Real Python
realpython.com โ€บ python-sets
Sets in Python โ€“ Real Python
May 5, 2025 - In this example, you call the method on a. Then, you call the method on the result of the previous call. The final result is the same as with the operator. ... The union, intersection, difference, and symmetric difference operators covered in the previous section have augmented variations that you can use to modify a set in place. Remember, sets are mutable data types, so you can add and remove elements from a set in place. Note: Python has a variation of sets called frozenset thatโ€™s immutable.
๐ŸŒ
Python Cheatsheet
pythoncheatsheet.org โ€บ home โ€บ sets
Python Sets - Python Cheatsheet
# discard() method: remove element, no error if not found s = {1, 2, 3} s.discard(3) # Remove element 3 (safe, no error if missing) s ... A. remove() removes one element, discard() removes all ยท B. There is no difference ยท C. remove() raises an error if element doesn't exist, discard() does not ยท D. remove() is faster ยท union() or | will create a new set with all the elements from the sets provided.
๐ŸŒ
Cisco
ipcisco.com โ€บ home โ€บ python set methods
Python Set Methods | Add | Discard | Union | Difference | Copy โ‹† IpCisco
December 24, 2021 - The first method that we will see here is python set add method. This method give us to add a new set item.
Top answer
1 of 2
2

I think it's just an (undocumented) artifact from the way set.itersection(*others) is implemented and therefore should apply to any other classes with methods that support a variable number of other objects.

To illustrate and prove my point, here's a custom class that supports this so-called "functional notation" via its own intersection() method.

Copyclass Class:
    def __init__(self, value=''):
        self.value = str(value)
        self.type = type(value)
        pass

    def __repr__(self):
        return f'Class({self.type(self.value)!r})'

    def intersection(self, *others):
        result = self
        for other in others:
            result &= other  # Perform via __and__() method.
        return result

    def __and__(self, other):
        return type(self)('|'.join((self.value, other.value)))


c1 = Class('foo')
c2 = Class('bar')
c3 = Class(42)
print(f'c1: {c1}')
print(f'c2: {c2}')
print(f'c3: {c3}')

# Both produce the same result.
print(c1 & c2 & c3)
print(Class.intersection(c1, c2, c3))

Output

c1: Class('foo')
c2: Class('bar')
c3: Class(42)
Class('foo|bar|42')
Class('foo|bar|42')
2 of 2
1

In addition to martineau answer, a method called through a class instance like obj1.method1(...) can also be called with obj1_class.method1(obj1, ...), and in the C implementation code I only see the assumption of the first argument to be a set. That is what happens too when you unpack others, this being a list of sets.

Maybe it is undocumented in the method help, but should be expected anyway.

So I also agree with

and therefore should apply to any other classes with methods that support a variable number of other objects.

๐ŸŒ
DEV Community
dev.to โ€บ usooldatascience โ€บ a-quick-guide-to-python-set-methods-with-examples-aap
A Quick Guide to Python Set Methods with Examples - DEV Community
September 11, 2024 - Below is a comprehensive guide to the commonly used set methods with brief examples. Adds an element to the set. ... Removes all elements from the set. ... Returns a shallow copy of the set. ... Removes an element from the set if it is present. Does nothing if the element is not found. s = {1, 2, 3} s.discard(2) # {1, 3} s.discard(4) # {1, 3} (No error) Removes an element from the set.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ set
Python Set (With Examples)
Here, we have used the len() method to find the number of elements present in a Set. Python Set provides different built-in methods to perform mathematical set operations like union, intersection, subtraction, and symmetric difference.
๐ŸŒ
UW PCE
uwpce-pythoncert.github.io โ€บ PythonCertDevel โ€บ modules โ€บ DictsAndSets.html
Dictionaries and Sets โ€” PythonCert 5.0 documentation
All Python sequences (including strings) have a count() method: In [1]: s = "This is an arbitrary string" In [2]: s.count('t') Out[2]: 2 ... In [1]: s = set() In [2]: s.update Out[2]: <function set.update> In [3]: s.update(['this', 'that']) In [4]: s Out[4]: {'that', 'this'} In [5]: s.update(['this', 'thatthing']) In [6]: s Out[6]: {'that', 'thatthing', 'this'}
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python set methods
Python Set Methods - Spark By {Examples}
May 31, 2024 - The set.copy() method is useful when you want to create a new set based on an existing set, but do not want to modify the original set. It is also useful as a way to create a backup of a set before making changes to it, as the copy is independent of the original set. # Create set original_set = {'Python', 'C++', 'Java'} # Create a copy of the set new_set = original_set.copy() print(new_set) # Output: # {'Python', 'C++', 'Java'} # Modify the original set original_set.add('Go') print(original_set) # Output: # {'Python', 'C++', 'Java', 'Go'} # Print the copy print(new_set) # Output: # {'Python', 'C++', 'Java'}
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ sets-in-python
Sets in Python - GeeksforGeeks
Python ยท s = {10, 50, 20} print(s) print(type(s)) Output ยท {10, 50, 20} <class 'set'> Note: There is no specific order for set elements to be printed ยท set() method in python is used to convert other data types, such as lists or tuples, into sets.
Published ย  May 16, 2016