I've only just started watching this video but I just want to say you're really talented and informative. I think you're excellent at conveying what's going on in a simplified way. I think this is the earliest I've ever been for one of your videos haha. Please keep doing what you're doing for the computer science and data science space! Sending you blessings from the UK☺
I was given a csv file with 524 columns of date times, instrument telemetry, etc...dataclass saved the day...just cut and paste the column header names and let the decorator do the rest. Also put the in-spec limits in the field's metadata along with LaTex strings for y-axis labels. 524...times. data class ftw.
Man this will be a good and convenient way of reduced my classes code in my current project. Thanks for such good content, and also at the perfect time 😜
I am still not conviced. Sure, for small classes with a few fields and logic it might be worth it. But in real world prod code you will have inheritance, polymorphism, logic, dependecies, etc. and you will end up having to implement all those "hacks" you mentioned. Simple classes will be much easier to understand and read and will have probably less overhead. Dont get me wrong, it is a nice tool to have in mind but call it AMAZING is a little too much IMHO. It would be much better if Dataclass just worked without having to implement all those hacks like post_init. I think it is designed to be use as placeholders for data you get from a database for example.
This decorator should be called @classes and inbuilt, without the need of a decorator 😊. Contrarily, with a @boilerplate decorator, that functionality could be then disabled, but I would like to see, how often that is going to be used 😅 It is the missing link for building a fully functional class without being bothered with boilerplate code. Which I believe would be best to not require anyway.
Tim, why is that bad practice in python, ref to list and list change between the calling of the same function? Is something to do with memory leaks or deconstruction / dangling pointers?
I understand the decorator and how useful it is when you are defining a class. You explain really well and your video is edited well. I am not going to use it though. I like to understand code completely and I feel that this approach "hides" potential clarity for the benefit of saving just a few lines of code that originally made the class more readable. It can get complicated if you keep adding parameters like order. Resistance to change, I guess.
Hello there Tim, am launching 200 days of python code challenge and am glad that you are that person who made me love python, but now tell me if there's away I should approach this 200 days of coding
hey , this is quite outside the topic , but anyone know how to fix could not find and load class main ( in java in vscode ) . By the way when i output the small code such as "hi" , "hello world " , it works but when i print a large lines of code , the terminal doesn't give me the output and the output keeps saying could not find and load class main ?
Well done. I wish instructors would at least mention that types are not necessary to write dataclasses. No field needs a type associated with it. Types are nothing but comments in Python, unless tools beyond bare python are invoked.
Hello Tim! How are you? I am going to be web developer in future. I downloaded VSCode. But I do not know how to start it. I need to start index.html and style.css I would be grateful If you could help me in this case.
@@goodlookinouthomie1757 in reality it depends on the scope of your programming. Need a quick and simple script that youre not gonna change just write global variables and operations. What you will find quickly enough is that some steps are repeated and you can write those steps as a function. Then you would use a mix of global and functional programming. If you continue scaling your project is that some variables are used in a section and not used any more, so it makes sense to separate those steps in to bigger functions, to save memory, also you would gain more flexibility as you would know which variables are used in each function and changing it once changes it for the whole script. If you continue scaling your project you may find some functions are called many times and each of those times something little changes, so you create a class that calls those functions and may change it. Another option is you want your script to have individual features and features that are a mix of the others, so a class could group those features (functions) as one and you can call them individually or in a group as your new function. So mainly you sacrifice more work to implement functions and or classes but gain flexibility or save lines of code for repetitions. Note this are examples and theres more pros and cons for using each paradigm.
@@simonmasters3295 If you put the first two functions into a class, these ones are called if you want a string representation for the class instance object. The class__repr function is used to list all parameters assigned to this instance. This is very handy, if you want to know what data an instance owns.
@@simonmasters3295 If you look at the code at 0:24, there is a static __repr__ method. If you add another instance property you would have to extend the method. The approach I am using is generic, you can use it on every class and it happily list all the properties recursively.
@@simonmasters3295 Please look at pos 0:24 in the video, the __repr__ function is static, if you extend the class, you have to extend the f-string. My solution is generic, it works for all classes. You can put the class__repr function in your own library, it lists all properties for an object using the classes __dict__ dictionary.
To learn programming and Python - check out Datacamp!
💻 Learn Python - datacamp.pxf.io/WqWaze
💻 Learn Programming - datacamp.pxf.io/EKrXPD
hey tim is this in the course?
@@MrRocka12 yes!
I've only just started watching this video but I just want to say you're really talented and informative. I think you're excellent at conveying what's going on in a simplified way. I think this is the earliest I've ever been for one of your videos haha. Please keep doing what you're doing for the computer science and data science space! Sending you blessings from the UK☺
I was given a csv file with 524 columns of date times, instrument telemetry, etc...dataclass saved the day...just cut and paste the column header names and let the decorator do the rest. Also put the in-spec limits in the field's metadata along with LaTex strings for y-axis labels. 524...times. data class ftw.
I've been watching old videos, so good to finally see you on VS Code! haha
Perfect timing for this video. I was able to use it right away in my project.
As a beginner in python I like your level of detail - a lot of youtubers make assumptions about the details of python.
Man this will be a good and convenient way of reduced my classes code in my current project. Thanks for such good content, and also at the perfect time 😜
I am still not conviced. Sure, for small classes with a few fields and logic it might be worth it. But in real world prod code you will have inheritance, polymorphism, logic, dependecies, etc. and you will end up having to implement all those "hacks" you mentioned. Simple classes will be much easier to understand and read and will have probably less overhead. Dont get me wrong, it is a nice tool to have in mind but call it AMAZING is a little too much IMHO. It would be much better if Dataclass just worked without having to implement all those hacks like post_init. I think it is designed to be use as placeholders for data you get from a database for example.
Oh this is wonderful, thanks Tim! 🎉
Great I'm going to use this to add autocomplete for json objects.
Oh, basically a decorator function that wrap a class. Nice
This decorator should be called @classes and inbuilt, without the need of a decorator 😊. Contrarily, with a @boilerplate decorator, that functionality could be then disabled, but I would like to see, how often that is going to be used 😅
It is the missing link for building a fully functional class without being bothered with boilerplate code. Which I believe would be best to not require anyway.
It's not gonna built-in because code generated by this is not cached
cool video Tim!
whtats the lookup method you use to get the value
Tim, why is that bad practice in python, ref to list and list change between the calling of the same function? Is something to do with memory leaks or deconstruction / dangling pointers?
Good topic, please continue
I understand the decorator and how useful it is when you are defining a class. You explain really well and your video is edited well. I am not going to use it though. I like to understand code completely and I feel that this approach "hides" potential clarity for the benefit of saving just a few lines of code that originally made the class more readable. It can get complicated if you keep adding parameters like order. Resistance to change, I guess.
Is this video part of a playlist?
Awesome video ! What switches do you have on your keyboard ? Does anyone know ?
12.30 time line the super().__init__(self.side, self.side) should be super().__init__(self.height, self.width) right?
I had the same thought. I noticed the mistake as well.
Hello there Tim, am launching 200 days of python code challenge and am glad that you are that person who made me love python, but now tell me if there's away I should approach this 200 days of coding
Just do it ffs
very useful, thx, bro.
Which theme are you using?
It's important to talk about __post_init__ because real code WILL need it, dataclass cannot do all the __init__ most times.
hey , this is quite outside the topic , but anyone know how to fix could not find and load class main ( in java in vscode ) . By the way when i output the small code such as "hi" , "hello world " , it works but when i print a large lines of code , the terminal doesn't give me the output and the output keeps saying could not find and load class main ?
go to stack overflow to get beat up and demeaned with a RTFM reply
Try a different name other than main and see if it works
Get out of here you're scaring the children
Try reinstalling java dependencies as well as check it in some other IDE just so you know there is not some IDE kind of error.
just hit alt-F4
Well done. I wish instructors would at least mention that types are not necessary to write dataclasses. No field needs a type associated with it. Types are nothing but comments in Python, unless tools beyond bare python are invoked.
So you can just create fields like:
class Point()
x
y
Can you?
Great tutorial
"AttributeError: 'dict' object has no attribute 'lookup'"
I try to run your code in the last example but end up with this, what is going on?
I use Vscode what is the theme name?
Thank you keep going
Hi tim do you know any thing about odoo developers
Would you recommend Python/Pygame for aspiring Android Game Developers?
Excellent
on post init: beware doing work in the constructor....
Hello Tim! How are you? I am going to be web developer in future. I downloaded VSCode. But I do not know how to start it. I need to start index.html and style.css I would be grateful If you could help me in this case.
Python flask will help! Render index.html static js and static css
this is super cool 😎 😎
Can you tell something about devin please? is coders's job dead?
It's same as record class in java
invents python because perl was too weird . Python becomes weirder .
I ❤ it's weirdness. 😊
I love the ide you are using can you share it with us ?
It’s VSCode
good
great video as always but.. am I the only one who heard him say "Codder" for color? :'D
Sublime?🤔
I think this is inspired from kotlin data classes
"Object-oriented programming an exceptionally bad idea which could only have originated in California"-Dijkstra
What's the better option and why? In terms that a beginner like me would understand.
@@goodlookinouthomie1757 are you asking why it is used?
@@GiannakYT Well just generally what is the alternative to OOP. And yes i suppose why you would use that.
@@goodlookinouthomie1757 Functional programming is an alternative.
@@goodlookinouthomie1757 in reality it depends on the scope of your programming. Need a quick and simple script that youre not gonna change just write global variables and operations. What you will find quickly enough is that some steps are repeated and you can write those steps as a function. Then you would use a mix of global and functional programming. If you continue scaling your project is that some variables are used in a section and not used any more, so it makes sense to separate those steps in to bigger functions, to save memory, also you would gain more flexibility as you would know which variables are used in each function and changing it once changes it for the whole script. If you continue scaling your project you may find some functions are called many times and each of those times something little changes, so you create a class that calls those functions and may change it. Another option is you want your script to have individual features and features that are a mix of the others, so a class could group those features (functions) as one and you can call them individually or in a group as your new function. So mainly you sacrifice more work to implement functions and or classes but gain flexibility or save lines of code for repetitions. Note this are examples and theres more pros and cons for using each paradigm.
i like this
func()
func() is crazy wtf is going on?
I found out, everything in python is a class object and every function definition runs like an object and its default parameters are like methods
I only ever use dataclasses when making classes
Lombok for Python it seems
please DO NOT USE THESE ANKWARD FACE CHANGES FOR THUMBNAIL LIKE OTHERS! its maybe working but it is stupid...
As a programing language, Python is a total failure. And it's success and popularity is a tragedy.
Huh ?
def __str__(self):
return self.__repr__()
def __repr__(self):
return class__repr(self)
...
def class__repr(classo):
d_ = classo.__dict__ # class dictionary
i = '
' if d_ else ' ' # indent
return f'{classo.__class__.__name__}() >'
I liked your code comment, but I don't understand it...
@@simonmasters3295 If you put the first two functions into a class, these ones are called if you want a string representation for the class instance object. The class__repr function is used to list all parameters assigned to this instance. This is very handy, if you want to know what data an instance owns.
@@simonmasters3295 If you look at the code at 0:24, there is a static __repr__ method. If you add another instance property you would have to extend the method. The approach I am using is generic, you can use it on every class and it happily list all the properties recursively.
@@simonmasters3295 trying to answer the third time ...
@@simonmasters3295 Please look at pos 0:24 in the video, the __repr__ function is static, if you extend the class, you have to extend the f-string. My solution is generic, it works for all classes. You can put the class__repr function in your own library, it lists all properties for an object using the classes __dict__ dictionary.