Vermutlich hat mir TH-cam ihren Kanal vorgeschlagen, weil ich auch Österreicher bin, Das war für mich ein Glücksgriff. Unprätenziöse, technisch hervorragende Information ohne Schnickschnack. Genau sowas brauche ich bei meinen verschiedenen Hobbies. Chapeau. Man sieht da ist ein absoluter Überflieger am Werk, der es nicht nötig hat, besonders unterhaltend und originell zu sein. Viel Erfolg. Dass Sie Österreicher sind habe ich erst bemerkt als Sie es gesagt haben.
noo, you can call foo or bar or whatever, there is no magic there. The only condition is to put it at the 1st position compared to the remaining attrs as dataclasses uses all the attrs in the defined order for comparison
Very 😎. I didn't even know this existed. My biggest complaint of programming in any language is the amount of boilerplate code needed to get anything more than "hello world" done. Repr/str/compare, etc in python, etc, getters n setters in the C farm of languages etc, etc. Etc. Not to mention the endless documentation, type hinting, etc etc etc etc (in etc sauce). Seems that this type of endless bs 'gotta be done' programming is where code completion models could really shine. You (the programmer) concentrate on the algorithm (state function, whatever), and the rest of the thing writes itself up to and through unit testing. Thanks tons! This is definitely going to help in quite a few places.
@@BobAg_ When putting up a shelf you could cut down a tree, trim the log, cut it, plane it, cure it, etc, however most peeps these days would buy a set of precut boards to suit their needs. I can't say I disagree with you about speed issues going through multiple layers of abstraction. Back in 'the good old days' we programmed right down to the metal in assembly. These days program requests are passed along to the O.S. supervisor for consideration, we'll get back to you when it's done. Clearly going to slow things down. In this case though I'm not really talking about performance issues, but rather programmer load, and how compilers and IDEs can help ease the keyboard workload. Say I'm in Python, and I'm creating um.. a bunch of game objects. Every time I create a new object I have to write REPR functions for each object type, which are for most intents and purposes identical. It would be nice if the IDE could at least automatically place a __repr__ stub including all variables defined in __init__. If I don't have to type that junk in, I can concentrate more getting through the hairier code instead of mindlessly tapping keys or even copy pasting. It may not seem like much case by case, but typing but all this junk in does take (cumulative and irreplaceable) time. Not so bad I guess if you're a salary enterprise programmer, who cares how long it takes as long as you get paid. It really tends to slow you down however if your trying to prototype a controller for your new laser potato masher (or whatever). Excess boilerplate code tends to lead to unnecessary errors and wasted time. Some languages are better than others in this regard. I just feel that this is in general a neglected aspect of language design.
Good video 🔔👍 I don't see the advantage of the sorting stuff? Added boiler plate, more verbose, decorator args and post_init! how is it better than using code comprehension? my_list.sort(key=lambda investor: investor.cash) or sorted(my_list, key=lambda investor: investor.cash, reverse=True) And how come sort_index got added at the top with defaults? Is this a special case because init = False?
I don't quite get how do you sort by cash, because, you define that the sort_index is equal to the cash, is this sort_index an special variable or something that the comparison method in dataclasses uses to actually compare the instances of the classes??
@@tapsfest23 - I too can guess that if sort_index has equality it moves on to comparing the other fields. That's why comparison for equality doesn't work if you're expecting it to compare only sort_index.
hey im trying to get into secutiy job, one of the resposibles it is to write phyton fuzzers, can you make simple video about it?
2 ปีที่แล้ว
15:05 Why do you need an extra field here? Can't you just use the existing `cash` field? Looks to me like that extra property only makes things worse since it has to be manually updated of the `cash` prop is updated.
the only downside i found atm is that whenever u have a default value set for a field, then all the fields that come after that one have to also be default, which includes subclasses, so if u inherit from a class with field that has a default value then that class can only have default value fields
At about 4:20 you are implementing __repr__() to modify the print output, I have seen it elsewhere too. I on the other hand had learned that you should use __repr__() in a way that calling eval() on the output will give you the objet back and you should implement __str__() if you want a nice presentation that is not for the machine. Am I missing something here, and there is a Good reason, or is it just "lazyness", because best practices are not allways best for you.
As bad as it sounds but NeuralNine often times makes mistakes that aren’t just mistakes that you do by accident. There is a big chance that he just doesn’t know. Look at his way of handling .endswith in his fuzzywuzzy video. He uses a generatorexpression inside a tuple() to have multiple file endings handled. Even though endswith already works with multiple.. he is just not a really good programmer. Edit: And he does this to do it: if file.endswith(tuple(c for c in list_of_endings) What he essentially did is cast a tuple from a list with a generator expression for every single file inside his directories.
hmmm, does it check for proper data types being entered into constructor, throwing Exceptions if not? Also can one define 'cross-class comparisons' with dataclasses? for example when i have the value of items from 2 different classes. I have made pretty custom-made class for a game and idk if dataclasses would be any usefull here, but sounds interesting Also - values set at 'post_init' work like @property decorated methods?
Let's say I want to write a script to retrieve Lan network IPs. In that case using Data class doesn't make sense. Just write simple functions or use normal class with __init__(). Found that concept of Data class confusing!!
Today is a great #MileStone for me that some might laugh at. But....I've been able to follow this WHOLE tutorial.... in a Jupyter Lab and EVERYTHING WORKS!! 🤯🤯🤯🤯🥵 🤝👏👏👏👏👏 #SimplyBrilliant and Thank You, Your videos are in my personal top 5 channels!!
Data classes are a code smell... The definition is a class with no behavior; it only contains fields, getters, and setters. The reason you should avoid these is because their data will often be manipulated by many classes in complex ways, and their lack of behavior means the class isn't doing anything to make up for having a name for its state, so its just more mental clutter to be aware of the data class in the codebase that doesn't even do anything. It also violates many OOP design principles, as the fundamental way data classes are used will lead to very low cohesion throughout the codebase.
Started re-learning python for the first time in 7 years, this video and your channel have been so helpful!
Vermutlich hat mir TH-cam ihren Kanal vorgeschlagen, weil ich auch Österreicher bin, Das war für mich ein Glücksgriff. Unprätenziöse, technisch hervorragende Information ohne Schnickschnack. Genau sowas brauche ich bei meinen verschiedenen Hobbies. Chapeau. Man sieht da ist ein absoluter Überflieger am Werk, der es nicht nötig hat, besonders unterhaltend und originell zu sein. Viel Erfolg. Dass Sie Österreicher sind habe ich erst bemerkt als Sie es gesagt haben.
Yeah.., Helmet
What's the intro music?
is sort_index is inbuilt variable for controlling the sorting ? Thanks for the great video.
noo, you can call foo or bar or whatever, there is no magic there. The only condition is to put it at the 1st position compared to the remaining attrs as dataclasses uses all the attrs in the defined order for comparison
Great video! I just was wondering what palette of colors are you using for your code in pycharm? It looks cool!
Atom One Dark
@@olivomiguel Wait, does pycharm have a light mode? It's always looked like this for me (as long as I can remember).
Thanks dude, makes life so much easier!
Excellent and high level toturial, keep up, thanks from Morocco
Very 😎. I didn't even know this existed.
My biggest complaint of programming in any language is the amount of boilerplate code needed to get anything more than "hello world" done.
Repr/str/compare, etc in python, etc, getters n setters in the C farm of languages etc, etc. Etc. Not to mention the endless documentation, type hinting, etc etc etc etc (in etc sauce). Seems that this type of endless bs 'gotta be done' programming is where code completion models could really shine. You (the programmer) concentrate on the algorithm (state function, whatever), and the rest of the thing writes itself up to and through unit testing.
Thanks tons! This is definitely going to help in quite a few places.
@@BobAg_ When putting up a shelf you could cut down a tree, trim the log, cut it, plane it, cure it, etc, however most peeps these days would buy a set of precut boards to suit their needs.
I can't say I disagree with you about speed issues going through multiple layers of abstraction. Back in 'the good old days' we programmed right down to the metal in assembly. These days program requests are passed along to the O.S. supervisor for consideration, we'll get back to you when it's done. Clearly going to slow things down.
In this case though I'm not really talking about performance issues, but rather programmer load, and how compilers and IDEs can help ease the keyboard workload.
Say I'm in Python, and I'm creating um.. a bunch of game objects. Every time I create a new object I have to write REPR functions for each object type, which are for most intents and purposes identical. It would be nice if the IDE could at least automatically place a __repr__ stub including all variables defined in __init__. If I don't have to type that junk in, I can concentrate more getting through the hairier code instead of mindlessly tapping keys or even copy pasting.
It may not seem like much case by case, but typing but all this junk in does take (cumulative and irreplaceable) time. Not so bad I guess if you're a salary enterprise programmer, who cares how long it takes as long as you get paid. It really tends to slow you down however if your trying to prototype a controller for your new laser potato masher (or whatever).
Excess boilerplate code tends to lead to unnecessary errors and wasted time. Some languages are better than others in this regard. I just feel that this is in general a neglected aspect of language design.
I am curious about that equal, perhaps when default sort function is the same, maybe it uses first value so john < mike if they have same cash?
the data classes are very useful, and scalable, but you can put documentation to each attribute, such as the property docstring?
Thanks for this video. It will make my work much more easier!
Good video 🔔👍
I don't see the advantage of the sorting stuff? Added boiler plate, more verbose, decorator args and post_init!
how is it better than using code comprehension?
my_list.sort(key=lambda investor: investor.cash)
or
sorted(my_list, key=lambda investor: investor.cash, reverse=True)
And how come sort_index got added at the top with defaults? Is this a special case because init = False?
It is so crazy, after watching python after working a while with JS and PHP, where are all the brackets?? 😂
I don't quite get how do you sort by cash, because, you define that the sort_index is equal to the cash, is this sort_index an special variable or something that the comparison method in dataclasses uses to actually compare the instances of the classes??
If I have to guess I think it takes the first value of the data class by default as he is defining it at the top.
@@tapsfest23 - I too can guess that if sort_index has equality it moves on to comparing the other fields. That's why comparison for equality doesn't work if you're expecting it to compare only sort_index.
Hey Nacho, great to see you leave cartel and started your own youtube..
i have learned a great deal of information about data classes , thanks
hey im trying to get into secutiy job, one of the resposibles it is to write phyton fuzzers, can you make simple video about it?
15:05 Why do you need an extra field here? Can't you just use the existing `cash` field? Looks to me like that extra property only makes things worse since it has to be manually updated of the `cash` prop is updated.
Making simple text rpg game seems like a great learning of classes
Indeed awesome, I didn’t find many gotchas to not use them. Will test them out, thanks!
the only downside i found atm is that whenever u have a default value set for a field, then all the fields that come after that one have to also be default, which includes subclasses, so if u inherit from a class with field that has a default value then that class can only have default value fields
This was helpful. Thanks.
At about 4:20 you are implementing __repr__() to modify the print output, I have seen it elsewhere too. I on the other hand had learned that you should use __repr__() in a way that calling eval() on the output will give you the objet back and you should implement __str__() if you want a nice presentation that is not for the machine.
Am I missing something here, and there is a Good reason, or is it just "lazyness", because best practices are not allways best for you.
As bad as it sounds but NeuralNine often times makes mistakes that aren’t just mistakes that you do by accident.
There is a big chance that he just doesn’t know.
Look at his way of handling .endswith in his fuzzywuzzy video.
He uses a generatorexpression inside a tuple() to have multiple file endings handled. Even though endswith already works with multiple..
he is just not a really good programmer.
Edit: And he does this to do it: if file.endswith(tuple(c for c in list_of_endings)
What he essentially did is cast a tuple from a list with a generator expression for every single file inside his directories.
@@lilDaveist fuzzywuzzy video? which one, could you please specify?
@@JohnMacPherson-hr4yz this one: th-cam.com/video/WNFBLi6CaTM/w-d-xo.html
This is amazing very well explained.
Another great video! Thanks for sharing!!
Can we use classmethods and staticmethods in dataclasses?
10:13 - class field name should be favorite_sport, pal, to respect Python snake_case PEP 8 guide Convention, sorry, I have to mention this...
Very instructive , i appreciate a lot.Thank you for shiring.
Thank you brooo.. You are awesome 🔥
hmmm, does it check for proper data types being entered into constructor, throwing Exceptions if not?
Also can one define 'cross-class comparisons' with dataclasses? for example when i have the value of items from 2 different classes. I have made pretty custom-made class for a game and idk if dataclasses would be any usefull here, but sounds interesting
Also - values set at 'post_init' work like @property decorated methods?
Thank you very much, this is very useful!
10:30 camelCase for JS but snake_case for Py please (if its not obvious Im just teasing, this guy is a great programmer)
This video is incredible.
Let's say I want to write a script to retrieve Lan network IPs. In that case using Data class doesn't make sense. Just write simple functions or use normal class with __init__(). Found that concept of Data class confusing!!
An easier approach to data classes, thanks for video. Keep it up!
Why does the i1>i4 return ´True´ if the __gt__ method is not implemented at the beggining?
I gues i1>i4 = not (i4
@@martijnb5887 correct. Python is smart enough to do this.
what is use case of this standard?
use instead of standard classes
Intro music please?
Thank you for the video. I am dipping my toes in python. Could you share a video on how to set up vim in windows for python program
Thank you , excellent detailed explanation.
As usually great explanation, Thank you :)
thanks buddy. its very useful
Today is a great #MileStone for me that some might laugh at. But....I've been able to follow this WHOLE tutorial.... in a Jupyter Lab and EVERYTHING WORKS!! 🤯🤯🤯🤯🥵
🤝👏👏👏👏👏 #SimplyBrilliant and Thank You, Your videos are in my personal top 5 channels!!
Nice 👍👍👍
How common is it to code on a windows machine?
Almost as common as it is to be a programmer.
so its just a helper that gets extended and doesnt even help with the thing you mentioned at 7:15 ? wow.
O waw I love your skills of explanation 👏 👌
Amazing; thanks!
Nice!
luved it
Thanks!
great video. thx
Ty so much
Thank you for your sharing
Data classes are a code smell... The definition is a class with no behavior; it only contains fields, getters, and setters. The reason you should avoid these is because their data will often be manipulated by many classes in complex ways, and their lack of behavior means the class isn't doing anything to make up for having a name for its state, so its just more mental clutter to be aware of the data class in the codebase that doesn't even do anything.
It also violates many OOP design principles, as the fundamental way data classes are used will lead to very low cohesion throughout the codebase.
Thx.
I love this channel
❤️ From India
Areeee bhau!
tnx
Sensei
From United States of India 😆🇺🇲🇮🇳
Lol
broooo looove your videos but maybe elaborate a little more and explain a little bit more
He explained alot 😂
If you want more....go to the documentation.
First comment!
+
firsttttttttttt
400 views 4 comments 😶😳
Why do I think this is worse?
First
freakin newbs just took and type.
Nice!