Python Data Structures: Sets, Frozensets, and Multisets (Bags)

preview_player
Показать описание

See how to implement mutable and immutable set and multiset (bag) data structures in Python using built-in data types and classes from the standard library.

A set is an unordered collection of objects that does not allow duplicate elements. Typically sets are used to quickly test a value for membership in the set, to insert or delete new values from a set, and to compute the union or intersection of two sets.

Python and its standard library provide several set implementations with different characteristics:

- The "set" built-in
- The "frozenset" built-in
- The "collections.Counter" class

Watch the video tutorial to see how sets work in general and how to use them in Python.

Articles mentioned in the video:

* * *

Рекомендации по теме
Комментарии
Автор

Your tutorials are really like the channel s name .. this one is real python

deusvult
Автор

Wonderful explanation but add time stamps for targeted navigation for viewers

encodedCoder
Автор

Thanks Dan, I recently learnt about this from the docs. Great explanation.

sto
Автор

Thanks again. I didn't know about Counters or frozen sets. Really useful stuff! Would be cool to see you making small rpg type game with all these neat Python tricks. I would enjoy watching like a 1 hour video of it.

koodauskanava
Автор

You hve not added link to 'what is hashable' that ccanbe added to sets.. Also can you state what is data structure in simple terms?

bronodude
Автор

Isnt the Counter class really a dictionary with a custom add item protocol defined? (Newb question sorry if its not accurate).. it kind of is right? I forgot multisets exist...

picosdrivethru
Автор

Well I used to call Counter or multiset a freq_dist

sehbanomer
Автор

Is there a compelling reason to use a Counter over a vanilla dictionary other than convenience/syntactical sugar? That .update() function is pretty slick

pnw_dev
Автор

Quick question: Isn't Multi-Bags example a 'dict' type, and not 'set()' ?

mehdizyoutube
Автор

Is this IDLE or something else? Because I love its theme!

clearlyajit
Автор

As a general question. What would be the pythonic way to express the following:



or...

journal_entry = user_input(cmd)

gcasanas
Автор

Is this how websites store user accounts? Seems like it can in a way.

impuresilver
Автор

Hey Dan!

Is there a way to have lists on a set besides getting a tuple version of those lists and append it to the set?

Danielagostinho
welcome to shbcf.ru