Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

Sets

Since sets are similar to dictionaries, they have a number of methods associated with them, which apply to both set and frozenset:

  • len(s): This returns the number of items in set s
  • x in s: This returns True if x exists in s;  otherwise, it is False
  • x not in s: This returns False if x exists in s; otherwise, it is True
  • isdisjoint(other): This returns True if the set has no elements in common with object other
  • issubset(other): This tests whether all elements in the set are also in other
  • issuperset(other): This tests whether all elements in other are also in set
  • union(*others): This returns a new set that includes elements from the original set and all other objects
  • intersection(*others): This returns a new set that only contains objects ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content