About 51 results
Open links in new tab
  1. Append values to a set in Python - Stack Overflow

    Aug 2, 2010 · Define a set Use add to append single values Use update to add elements from tuples, sets, lists or frozen-sets ... Note: Since set elements must be hashable, and lists are considered …

  2. python - Best way to find the intersection of multiple sets? - Stack ...

    707 From Python version 2.6 on you can use multiple arguments to set.intersection(), like ... If the sets are in a list, this translates to: ... where *a_list is list expansion Note that set.intersection is not a …

  3. python - How do I add two sets? - Stack Overflow

    Apr 15, 2015 · Sets are unordered sequences of unique values. a | b, or a.union(b), is the union of the two sets — i.e., a new set with all values found in either set. This is a class of operations called "set …

  4. python - Difference between union () and update () in sets, and others ...

    Python sets have these methods for all the standard relational algebra operations: s.union(t) s | t new set with elements from both s and t s.update(t) s |= t return set s with elements added ...

  5. Union of multiple sets in python - Stack Overflow

    Jun 11, 2015 · Union of multiple sets in python Ask Question Asked 10 years, 10 months ago Modified 3 years, 10 months ago

  6. Use curly braces to initialize a Set in Python - Stack Overflow

    I'm learning python, and I have a novice question about initializing sets. Through testing, I've discovered that a set can be initialized like so: my_set = {'foo', 'bar', 'baz'} Are there any

  7. python - Add list to set - Stack Overflow

    Aug 20, 2009 · Sets can't have mutable (changeable) elements/members. A list, being mutable, cannot be a member of a set. As sets are mutable, you cannot have a set of sets! You can have a set of …

  8. Efficiently compare two sets in Python - Stack Overflow

    Efficiently compare two sets in Python Asked 8 years, 7 months ago Modified 2 years, 2 months ago Viewed 88k times

  9. python - How is set () implemented? - Stack Overflow

    According to this thread: Indeed, CPython's sets are implemented as something like dictionaries with dummy values (the keys being the members of the set), with some optimization (s) that exploit this …

  10. Python sets: difference () vs symmetric_difference ()

    Jun 15, 2018 · What is the difference between difference() and symmetric_difference() methods in python sets?