Python 3 - Classes vs Dictionaries

preview_player
Показать описание
A comparison of a basic class and a dictionary. We will mimic the functionality of a class with a dictionary, but you will see that the class offers a nicer syntax and has a few more features.
Рекомендации по теме
Комментарии
Автор

I had just learned up on classes and was missing how they were significantly different from dicts, thanks for the video!

Lich
Автор

Fantastic tutorial. I've just started programming in Python, and I loved dictionaries and hated classes lol. But now it sounds like classes are just dictionaries (and therefore just as fast) but with much better syntax under some circumstances, such as when the value in the dictionary is a tuple of variables. Thank you.

bp
Автор

Hey man...BEAUTIFUL video! I was thinking that I would need to do exactly what you did here to help me sort out the difference between classes and dictionaries. I'm trying to break my scripting habit, and utilize more functions and classes...Returning dictionaries was my first idea, now I see that Classes are nothing more than an elegant way to manage dictionaries, with some additional advanced capabilities.

This is the gold standard on teaching this topic as far as I'm concerned.

Kevinschart
Автор

Great video!!! Thank you for making it so much clear now what the actual benefits of using Classes are. For a beginner, who's gone along just fine with dictionaries, it wasn't too obvious.

P. S I tried to go through your playlists to see what other uploads you have on a topic of Python; It would be immensely helpful if you could create a dedicated playlist for Python too.

Thank you

ep
Автор

Very well done
I come from a c-sharp background but I've been riding python for the last 6 months or so
I've gotten lazy and I tend to use dictionaries for everything
Because c sharp is a statically typed language you don't really have that option
I'm watching this video has reminded me of why design patterns based on classes are more efficient in the long run
Great video

immanuelsuleiman
Автор

please make the font a bit bigger on the screen. Thanks

MusicEffekt
Автор

Thanks for this explaination, there is a lot of these classes and dict method used in machine learning libraries. I'm trying to make and modify according to my needs, but its quite difficult then I thought, since I am coming from a mt4 😍

azrulfyz
Автор

For holding data, you might prefer dataclasses. For simple and non-volatile storage and portability, you might prefer the dictionary so you can serialize it with JSON.

Gruuvin
Автор

nice video. please continue making this type of tutorial, I'm a python beginner and I really want to get deep into it. thanks, new subscriber here

marcjosephcole
Автор

Forgot to say thanks for the video man, amazing job explaining. You have a talent for teaching for sure. Classes clicked for me about 13 mins in 🫰

moralfuxery
Автор

This was very good tutorial, thank you!

BogdanBogdanovichBogdanov
Автор

I thought perhaps you were going to go the __repr__ route in the class but you have to stop somewhere. Those helper functions really make integration of classes with standard functions behave nicely.

markasiala
Автор

So look, im at the of a programming class, and we ended eith python and only spent 2 weeks on it which i hate. Dictionaries throw me off right now, but classes clicked IMMEDIATELY with me. Someone thats baddass with this language, is it bad to just move forward using classes? They seem to serve the same purpose just a different way of getting there. Is all the same functionality there still? Has in if i wanted to retrieve data set in the class earlier to be called on way down the line for another function. Also cant figure out how to make a class, but have the input() place that data into it. 🧐

Again, note, that i just started with Python but strong understanding of this area of study. We literally study everything but how to code (other than shell scripts, do of those) (im a CS/InfoSec student)

moralfuxery
Автор

what if i wanna put a dictionary into a class, does that make sense?

pangyongray
Автор

Why didn’t you use print_basket(di_a) instead of di_a[“print_basket”](di_a) ? Couldn’t you have got this result without creating a new key in dict? 29:09

OzturkCan
Автор

Great video. Is there a substantial difference in memory/efficiency between storing variables in dictionaries vs classes

heatherbaroody
Автор

# This is the dictionry
pips = {"Tie":1, "Noah":2, "Ma":3, "rye":4, "Law":5, "shoe":6, "Cow":7, "ivy":8, "Bee":9, "Toe":10}
# Request the user pick a number to the associated Key
Peg = input(“ pick a number from 1-10 ” + pips [ ])
Print(“This is your associated key ” + peg)
#How do you get the associated user input to the dictionry?

thairston
Автор

hey super thanks man, can you share the code, I know its not a lot of code to write, but its a little bit easier for us to copy and play with it to better understand your story

UnpluggedPerformance
Автор

This is a weird example, you are creating a dictionary for each key-value pair but usually dictionaries are used to hold more than one of these, you should have apples, bananas and cranberries all in one dictionary with their correspondong values.
How would you do that in a class?
How would you add key-value pairs to the class without knowing, how many they are in advance like using a for loop with hundreds of key-value pairs?

leecaste
Автор

print("good video dude".title())

antiquarian