Just a clarification, in your pep8 coding guidelines videos, I see you saying coding convention for factory functions and i don't see the same while declaring the static method random_artist using @staticmethod decorator. Is it because you have defined the random_artist in a class or you should have defined it as RandomArtist. Please clarify.
2 ปีที่แล้ว
I would say it's a judgment call. Personally, I would use ThisNamingConvention only for functions that really look like they're classes. A static method, even if it returns an object, is clearly a function, and so I would personally use this_naming_convention. But in the end it's just a convention, and you should choose the naming style that will feel most intuitive to the user!
A statimethod can be used for anything, and not generally for any purpose. Say you want a method that when you pass it a number it multiplies it by 5. That method could easily be outside the class or if you want it to be inside, just add @staticmethod to it.
Yoooo I'm super geeked and impressed with his knowledge of urban music! that's tight! good ish yo PS. Great explanation also.... So the object, dunder class dunder hits (rr._class.__hits()) is a way around the "private" or mangled properties of certain attributes! Nice nice!
You said that static methods are used to implement factory functions. Aren't classmethods used for that? They are used to provide alternate constructors.
7 ปีที่แล้ว
That's a good point. Yes, you can use a class method for that as well, and they actually have a slight advantage, because they can use the cls argument to refer to the current class, rather than explicitly referring to it by name (as I'm doing in this video). That's especially convenient during subclassing. But you can use static methods as well in most cases.
i use python 3.7 with a pycharm editor,...and its what i learned with. im not familiar with some methods you used like the getter method, and the part where you said there is a convention which you are required to place an undersore when creating a variable in self.....normally in pycharm, i just do 'self.name = name' and it works just fine. And i also dont need the getter method to print out a name from an object. i just do object.name, and it prints out the argument
1-This is more related to classes than it is to decorators 2-knowing that a function returns a value, for some given data, assume you want to use that returned value in another function, so you use that function as an argument in the other function or you add the other function as a decorator, decorating the return of function one
Asaad Najjar Well, I searched for decorators on youtube and it gave me this video. And obviously..@property, @staticmethod, and @classmethod are clearly decorators. So it's pretty much about decorators. 🙂
@Micheal Olu : The underscore is used to make the variable visible / accessible only for methods within a class. These are similar to private variables in Java. To make those variables accessible you can use methods (like getters). A key advantage of using the getter n setter is that since it is a function, you can add some pre-processing login (e.g: Convert value to uppercase or append a string). Think about good practices for developing python code , rather than making the code just work. That'll make the code much more readable & maintainable in the long run.
What is that high-pitch ringing noise in the background? I would encourage you to run your video's audio through a pass-filter before publishing. Other than that, I'd say this is a great video! Not trying to be rude, I just thought you could use a bit of constructive criticism.
When you don't use the underscore, the code gets into a infinite loop. Don't know why, but it happens.
6 ปีที่แล้ว
It sounds like you're having the name property return itself, is that right? That would indeed cause an infinite loop, in the same way that a function that (unconditionally) calls itself results in an infinite loop and eventually a RecursionErrror.
Small and excellent video, really rare to see such tutorials, to the point & very nicely explained , Thumbs up for you !!!
+mohit048 thank you!
yes yes yes love your channel 💪
Wow!! Zero BS and straight to the point.
Those guys are great but this explanation is more precise than that of Corey Shafer and Dereck Banas.
Great job!
Took 5 videos to try to grasp classmethod, but i think yours finally got me there... I think...
this was really helpful . thanks. please keep making tutorials. u are helping the community !! bless you
your explaining is 10/10
This is an outstanding example that explained everything for me. Thanks !!
Thanks for your video, now I understand clearly the decorator property.
This is great tutorial. Now it's clearerto to me now the use and importance of those methods
The coolest Python teacher :))). Ty 4 the video dude. It helped me a lot! :D
If you apply these types of examples in all your python videos, you can create a product that kids in inner cities can grasp onto.
Amazing! Thanks for sharing your knowledge! Very nice step-by-step teaching style!
I hope someday I could understand it fully!
Take your time and you will!
Good explanation, looking forward to watching more videos.
Just a clarification, in your pep8 coding guidelines videos, I see you saying coding convention for factory functions and i don't see the same while declaring the static method random_artist using @staticmethod decorator. Is it because you have defined the random_artist in a class or you should have defined it as RandomArtist. Please clarify.
I would say it's a judgment call. Personally, I would use ThisNamingConvention only for functions that really look like they're classes. A static method, even if it returns an object, is clearly a function, and so I would personally use this_naming_convention. But in the end it's just a convention, and you should choose the naming style that will feel most intuitive to the user!
@ thank you for the quick reply, what you say makes sense in a way.
A statimethod can be used for anything, and not generally for any purpose. Say you want a method that when you pass it a number it multiplies it by 5. That method could easily be outside the class or if you want it to be inside, just add @staticmethod to it.
Yoooo I'm super geeked and impressed with his knowledge of urban music! that's tight! good ish yo
PS. Great explanation also....
So the object, dunder class dunder hits (rr._class.__hits()) is a way around the "private" or mangled properties of certain attributes! Nice nice!
Regarding staticmethod part:
When I delete the "@staticmethod" line, the Code works in the Same way. Shouldnt it have some effect?
Good, shot and consistent vid!
Glad you like it! 😊
One of the best explanation.
dude this is so good! I completely understood how to use these after this video. subscribed!
Glad you found it useful!
that moment when you say YOung Jeezy - In the mix......
Dude... Thank you for existing. Very clear!
Nice explanation brother, keep up the good work 👍
Dude u r just damn good 👏👏
That's what she said.
Great Content! Also Love ur FaceCam Style!!
Nicely done
Very useful and well explained, thanks a lot!
I love this guy
Super CLEAR!
Instead of "Rick Ross" I always understand "Rick Rolls" lmao 😂
Great explanation!! What terminal are you using that shows the code on top and output on the bottom?
That's a Jupyter Notebook. Very convenient for cases where you want to show both the result of your code, and the code itself!
10:13 isn't it simply adding a new field, called self._hits to the instance of the class?
Great demonstration by the way, thanks.
Yes, that's exactly what happens!
Nicely explained.🔥
this is packed with information!! thank you so much bro! great job
Thanks Sebastiaan. I would love to follow your more and more tutorials. Keep it up :)
Thanks for a great video!
Awesome man. So thanks
Very nice. Please upload more videos.
There you go! th-cam.com/play/PLR-r0edywujd8D-R2Kue1C_wYEK_4Ii71.html
really golden guy!
I assume that random_artist() calls the class constructor TrapArtist in the return statement for this to work
How do you use this method to match two dataframes
How are ur sunglasses called?
Awesome,
Great stuff, thank you
You said that static methods are used to implement factory functions. Aren't classmethods used for that? They are used to provide alternate constructors.
That's a good point. Yes, you can use a class method for that as well, and they actually have a slight advantage, because they can use the cls argument to refer to the current class, rather than explicitly referring to it by name (as I'm doing in this video). That's especially convenient during subclassing. But you can use static methods as well in most cases.
i use python 3.7 with a pycharm editor,...and its what i learned with. im not familiar with some methods you used like the getter method, and the part where you said there is a convention which you are required to place an undersore when creating a variable in self.....normally in pycharm, i just do 'self.name = name' and it works just fine. And i also dont need the getter method to print out a name from an object. i just do object.name, and it prints out the argument
Michael Olu why are you watching if you don’t know what you are watching
Asaad Najjar I'm trying to understand decorators in python
1-This is more related to classes than it is to decorators
2-knowing that a function returns a value, for some given data, assume you want to use that returned value in another function, so you use that function as an argument in the other function or you add the other function as a decorator, decorating the return of function one
Asaad Najjar Well, I searched for decorators on youtube and it gave me this video. And obviously..@property, @staticmethod, and @classmethod are clearly decorators. So it's pretty much about decorators. 🙂
@Micheal Olu : The underscore is used to make the variable visible / accessible only for methods within a class. These are similar to private variables in Java.
To make those variables accessible you can use methods (like getters). A key advantage of using the getter n setter is that since it is a function, you can add some pre-processing login (e.g: Convert value to uppercase or append a string).
Think about good practices for developing python code , rather than making the code just work. That'll make the code much more readable & maintainable in the long run.
Damn, u really like Rick Ross. It's not the first time u mention his name in your tutorials
I love the fact that you like hip-hop!
great video!
mooi! but why are you having those sunglasses :P
I overcompensate.
Thanks Seba
Чувак, какой же ты крутой
Knows his code well, knows hiphop too! who said we're geeks huh??!!
YESSS GREEN/BLUE/RED/BLACK --
thank you
What is that high-pitch ringing noise in the background? I would encourage you to run your video's audio through a pass-filter before publishing. Other than that, I'd say this is a great video! Not trying to be rude, I just thought you could use a bit of constructive criticism.
When you don't use the underscore, the code gets into a infinite loop. Don't know why, but it happens.
It sounds like you're having the name property return itself, is that right? That would indeed cause an infinite loop, in the same way that a function that (unconditionally) calls itself results in an infinite loop and eventually a RecursionErrror.
Thank you m8. Great channel by the way.
Damn... So cool
Ricky Rosé approves this message
+Jaspreet Sahota of course he does
My red flag went up in the @classmethod discussion ...
nice
Geod un bedankt
we want more !!
JUST WOOW
How do you know so many trap artists.. haha
&&OO in a TOPdown VISUAL_Editor_what`s wrong? see my FUNCTION: DATA: ERROR :
U look like Nick Jonas
Jonas brother by day. Python coder by night.