Python OOP Tutorial 6: Property Decorators - Getters, Setters, and Deleters

In this Python Object-Oriented Tutorial, we will be learning about the property decorator. The property decorator allows us to define Class methods that we can access like attributes. This allows us to implement getters, setters, and deleters. Let's get started.
Python OOP 1 - Classes and Instances - • Python OOP Tutorial 1:...
Python OOP 2 - Class Variables - • Python OOP Tutorial 2:...
Python OOP 3 - Classmethods and Staticmethods - • Python OOP Tutorial 3:...
Python OOP 4 - Inheritance - • Python OOP Tutorial 4:...
Python OOP 5 - Special (Magic/Dunder) Methods - • Python OOP Tutorial 5:...
Python OOP 6 - Property Decorators - • Python OOP Tutorial 6:...
The code from this video can be found at:
github.com/CoreyMSchafer/code...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Пікірлер: 968

  • @mariosconstantinou8271
    @mariosconstantinou8271 Жыл бұрын

    Even after 6 years, this series about OOP is amazing. Thank you Corey

  • @yBazo82

    @yBazo82

    11 ай бұрын

    this helped me so much legit

  • @Poerak

    @Poerak

    11 ай бұрын

    Also suprised how accurate and applicable it still is. Really glad I spend the 3 hours learning this.

  • @rijuroy7415

    @rijuroy7415

    11 ай бұрын

    @@Poerak Really it's amazing.

  • @tejasvakhandelwal9951

    @tejasvakhandelwal9951

    10 ай бұрын

    Really still this content taught me a lot

  • @_theashishbhatt

    @_theashishbhatt

    7 ай бұрын

    I agree. I first came across Corey in 2017, was just looking into python at that time but also liked the DIY stuff he did. BTW, @Coreyms with changes in python, has anything become outdated? I was planning to go through the entire playlist.

  • @kevinzhang8974
    @kevinzhang89745 жыл бұрын

    I watched this whole series (OOP) 3 times and code along with it. I have to say this is so far the best videos I have watched to explain Pyhon OOP. I learned some much from it ... Thanks you!

  • @allinman4028

    @allinman4028

    5 жыл бұрын

    Same here

  • @uplift_therapy

    @uplift_therapy

    5 жыл бұрын

    Yup!! Yup!!

  • @TrungNguyen-ld7hz

    @TrungNguyen-ld7hz

    5 жыл бұрын

    same here, in 2019.

  • @alekhandrosuarez2832

    @alekhandrosuarez2832

    4 жыл бұрын

    Same here! 2020. Thanks Corey! The reason peaple are watching this couple of time is that here you get extremely concentrated and straightforward understanding of OOP itself. Rather then just talking of syntax. The entire series is about an hour lonh, no rubbish, all clear, but there is so many usefull information, that a newbie just can't memorize all of that at once. So I use this series as a handbook. Thanks one more time!

  • @alekhandrosuarez2832

    @alekhandrosuarez2832

    4 жыл бұрын

    BTW for some reason I've been watching from different of my accounts and likes where coming from all of them. :)

  • @danpickford3894
    @danpickford38944 жыл бұрын

    If i can learn OOP at 2am in quarantine without the use of my singular brain cell then the explanation must be doing something right XD

  • @Hsa008

    @Hsa008

    4 жыл бұрын

    😄😂😂😁😀😅😅😆😆😆😉

  • @srikarrepaka5023

    @srikarrepaka5023

    4 жыл бұрын

    I am learning it at 4:50 am 😇😂😂

  • @danpickford3894

    @danpickford3894

    4 жыл бұрын

    @@srikarrepaka5023 where you at my guy cos now i'm tryna learn a* at 2:10 am , us guys have no lives do we? edit: I just realised that I seem obsessed with coding at 2am, I have MANY problems and... apparently 2am is one of them...

  • @wave8889

    @wave8889

    4 жыл бұрын

    I lean at 0:30 am and tomorrow is the exam xD

  • @easyscience2235

    @easyscience2235

    4 жыл бұрын

    Exactly what I am doing right now, when the mind is clear xD

  • @Skaxarrat
    @Skaxarrat5 жыл бұрын

    Holy shit, in a bit of an hour I've understood concepts that would take hours to understand and fix the information in my brain. Thanks Corey P.D: You need to write a Python book

  • @aidensmith6277

    @aidensmith6277

    5 жыл бұрын

    I second this. I would buy it in a flash 😁

  • @truphenalwanga9829

    @truphenalwanga9829

    5 жыл бұрын

    yes and start a school too. In fact a chain of schools

  • @yellowswordg

    @yellowswordg

    5 жыл бұрын

    I would buy it as well.

  • @ashutoshagrawal3076

    @ashutoshagrawal3076

    5 жыл бұрын

    Why don't open your own MIT

  • @azekhuoriadignity2360

    @azekhuoriadignity2360

    5 жыл бұрын

    I prefer videos to books

  • @petenilson
    @petenilson7 жыл бұрын

    One of the clearest explanations of this that I've seen before. Thanks very much!

  • @copyrightedchannel4939

    @copyrightedchannel4939

    3 жыл бұрын

    are you working to google now? 😄

  • @5uperM

    @5uperM

    2 жыл бұрын

    For sure.

  • @drygordspellweaver8761

    @drygordspellweaver8761

    2 жыл бұрын

    5 years ago - wish I had been studying python instead of following the trump election drama

  • @obed818

    @obed818

    2 жыл бұрын

    @@copyrightedchannel4939 lol ^^

  • @akhilmachaan5010

    @akhilmachaan5010

    Жыл бұрын

    ​@@copyrightedchannel4939 Can you explain why the email was not updated in the begginning.I didn't understand that part.

  • @FaberLSH
    @FaberLSH23 күн бұрын

    The best series ever!! I never learned so much about class as I'm learning here today in 2024!

  • @SantoshkumarPandeySKCP
    @SantoshkumarPandeySKCP20 күн бұрын

    You made it seem so easy to understand throughout this OOP playlist. Thank you.

  • @allinman4028
    @allinman40285 жыл бұрын

    I had no coding experience. I followed beginner series and OOP series and coded along with them with my little three kingdoms game concept. I feel I built great a solid fundamental understanding of Python. It will be extremely useful for my future coding journey. Thank you so much, Corey.

  • @slimyelow
    @slimyelow5 жыл бұрын

    Took me all morning coding and documenting along, but finally got my grip on this. Yay Corey !

  • @AhmedKhan-yw3wx
    @AhmedKhan-yw3wx9 ай бұрын

    I finally learned what property decorators are, thank you Corey!

  • @bsmaheshkumar5328
    @bsmaheshkumar53282 жыл бұрын

    His quality of explaining is next level, Thanks, buddy.

  • @CalvinJKu
    @CalvinJKu6 жыл бұрын

    Best python channel ever. This decorator thing has troubled me for so long!

  • @ninakoch1799
    @ninakoch17993 жыл бұрын

    Thank you, thank you, thank you. Spent 13 weeks trying to learn the basics of oop at college, decided to start watching your series 3 days before my test and i think i finally truly understand the concepts, whereas before watching this i was pretty much just copying stuff from my lecture notes and didnt really understand why it did or didnt run properly. Corey, you are an incredibly gifted teacher and i feel blessed to be your student.

  • @Schian

    @Schian

    Жыл бұрын

    I know it is a bit of a necro post. How did your test go?

  • @colinmanko7002
    @colinmanko70025 жыл бұрын

    Perfectly paced. Watched all 6 parts of ‘Working with Classes’ without needing to pause. Corey goes over concepts in a logical order and without fluff (as a good programmer would). I’ll be back!

  • @alexisaddicted
    @alexisaddicted4 жыл бұрын

    Unbelievable quality of this content, well done! Simple yet concise and to the point. Helped me a ton, thanks!

  • @imranayari
    @imranayari3 жыл бұрын

    After weeks of learning of OOP in python using other sources and I couldnt understand, now in 60 minutes plus, I was able to understand the concepts and logics behind OOP. Thanks Corey Schafer

  • @peterchen5710
    @peterchen57104 жыл бұрын

    Corey champ, you are unreal! I can't thank enough for the way you explain the concepts/designs, you dont just show me how things works, but you help me UNDERSTAND how things works. I will be sure to show my appreciation via Paypal once I get a dev job, thank you!

  • @Pramesh37
    @Pramesh37 Жыл бұрын

    You're a life saver. Although I knew OOPS, I wanted to brush up to get my concepts clear. You explained concepts in such a way that I don't need to brush up on OOPS ever again! Thanks a ton.

  • @dr_920
    @dr_9204 жыл бұрын

    Thank you so much for spending time on preparing the Class series. I've learned a ton from them.

  • @nissan5563
    @nissan55632 жыл бұрын

    I already watched your multiple videos including this OOP series and there is no doubt that I enjoyed it so much. Most appreciating point for me that, your neat and clean explanation without repeating or adding any unnecessary words. Please continue with more videos

  • @venkysmoments9155
    @venkysmoments91555 жыл бұрын

    Your way of explaining and breaking things into smaller and understandable way is awesome. You are an great tutor.Learned lot of stuffs from your tutorials. My longtime wish from me is please make videos regarding Multithreading and MultiProcessing. So that all of us can make utilize and learn these concepts in a simplified manner.

  • @dustinhxc
    @dustinhxc Жыл бұрын

    This series was amazingly eye opening! You’re the best! Thank you! Such a wonderful prepared teacher!

  • @Given_A
    @Given_A6 ай бұрын

    Watching in 2024 and still learnt alot. Thanks Mr Corey!

  • @dilpreetsinghnagra
    @dilpreetsinghnagra4 жыл бұрын

    I have watched his almost every video related to python and believe me he explained to me clearly every concept that I wanted to study related to python

  • @daevski
    @daevski5 жыл бұрын

    Bro, this is genius; I understood this example very clearly, and I was struggling to understand @property otherwise. Thanks so much for this awesome example!

  • @milindsabnishd
    @milindsabnishd Жыл бұрын

    I couldn't understand 'Decorators' concept anywhere, but you made it so simple. Thanks a ton, Corey Sir.

  • @anirvansen2941
    @anirvansen2941 Жыл бұрын

    Awesome, Corey's playlist is the best place to brush us on python concepts. Thank you again

  • @remzgr
    @remzgr3 жыл бұрын

    I am a non-programmer trying to learn Python and this series has been an absolute boon when compared to the other courses! Thankyou very much Corey!

  • @deadbod4

    @deadbod4

    3 жыл бұрын

    I second this

  • @akhilmachaan5010

    @akhilmachaan5010

    Жыл бұрын

    @@deadbod4 Can you explain why the email was not updated in the begginning.

  • @deadbod4

    @deadbod4

    Жыл бұрын

    @@akhilmachaan5010 i cant, i quit learning python and went full crypto

  • @jiakai7254

    @jiakai7254

    Жыл бұрын

    @Akhil Machaan the email is an attribute that got initialized with the old first_name and last_name. To change the email, you would need to create a method that accesses the first and last names, but then all the existing code will have to be changed to access email like a method. the getter allowed us to define a method for email that can be accessed like an attribute so there's no need to change the existing code.

  • @nimaliberty4734
    @nimaliberty47346 жыл бұрын

    Hi there Corey, YOU are a GENIUS. your VIDEOS are the BEST on youtube. I wanted to give up till I came across your videos. You are a life saver. A big THANKS to a HERO THAT YOU ARE.

  • @jakebirkmaier5703
    @jakebirkmaier5703 Жыл бұрын

    I've been using a python OOP API for maybe a year on and off (thousands of lines/hundreds of hours) and never truly understood classes because I couldn't find a video series that explained them this well. This playlist has been so excellent for me and I appreciate you putting it together!

  • @MdAzhar-kx7op
    @MdAzhar-kx7op6 жыл бұрын

    Have never seen such a great tutor like you. everything you made so simple and easy to understand. thanks a lot man.

  • @mrshyam538
    @mrshyam5385 жыл бұрын

    You are a great teacher... I have been following through all your playlists and i have learned a lot in so little time. Thank you so much whole heartily

  • @kavabangaungava
    @kavabangaungava5 жыл бұрын

    This is a brilliant example of how to explain complex things in simple language!

  • @kvnptl4400
    @kvnptl44004 жыл бұрын

    superb series of 6 videos on Python OOP concepts, learned a lot. Thank you Corey!

  • @dhananjay4525
    @dhananjay45259 ай бұрын

    Bhaiya, bahut bahut dhanyawaad.....One of the best explanations on getters and setters in python across youtube

  • @shivajishinde1496
    @shivajishinde14965 жыл бұрын

    The best python teacher I ever had. Thank so much for providing highly valuable information. I like your accent very much!!

  • @JonathanHobbe
    @JonathanHobbe5 жыл бұрын

    Finally someone that explains it so you understand the logic behind it! Thanks so much!

  • @byheartgeeta
    @byheartgeeta2 жыл бұрын

    I finished this in a single sitting along with the practice. I can't explain how precious this content is. more power to you @Corey. so much love from India.

  • @cinnion
    @cinnion6 жыл бұрын

    Great refresher series for something I have not heavily used for *mumble* years (I started around 1.0 and remember 3.0 was a future release last I used it heavily). Well structured, building one relatively short video on top of another.

  • @Mainhunpyarkamusafir
    @Mainhunpyarkamusafir5 жыл бұрын

    Can't believe This channel was there and I found it now ... Awesome Corey .. I never understood these concepts before :)

  • @saitaro
    @saitaro7 жыл бұрын

    Glad I found your channel...

  • @zihanchen4312
    @zihanchen43123 жыл бұрын

    If there is a Competition on the Internet to choose which is the best channel for Python Programming, I would vote for this channel with no hesitation. Huge Respect!

  • @vman049
    @vman0494 жыл бұрын

    Just binge watched the entire series. Great explanations and a great reference to come back to. You're the best!

  • @tivasalvation
    @tivasalvation4 жыл бұрын

    This is good! I actually just came here to learn the OOP. I just found myself going through the whole channel. The lectures are great 👌

  • @gravnine

    @gravnine

    3 жыл бұрын

    Same here!

  • @czagazeta
    @czagazeta5 жыл бұрын

    Thank you for this series! Your series cleared up a lot of the confusion I had about OOP in Python. I sent some BTC, and likes your way. Cheers!

  • @ibrahimal-mahfooz8737
    @ibrahimal-mahfooz87374 жыл бұрын

    Such a clear and clean tutorial. I really benefited from this a lot when I studied for encapsulation.

  • @noyou9349
    @noyou934911 ай бұрын

    Honestly, this series is the best I've ever seen on OOp. It's concise, clear, and the explanations are good. I'll say it again, I wish I had found this series when I was learning OOP. Good job

  • @PavansnSMG
    @PavansnSMG7 жыл бұрын

    Impressive. I just love these videos. They made Python even more interesting. Thanks Corey. Keeping making videos like this and help novice programmers like me :P

  • @TonyFlexPromo
    @TonyFlexPromo6 жыл бұрын

    This one is actually blowed my mind. Thank you for this tutorials!

  • @chrismalingshu
    @chrismalingshu4 жыл бұрын

    it's a WOW moment! never thought that these property decorators could be that powerful! Amazing :) Appreciate it a lot!

  • @Tadae323
    @Tadae3237 жыл бұрын

    Seriously, checked the whole Internet and your tutorials are the best.

  • @aidensmith6277
    @aidensmith62775 жыл бұрын

    Other tutorials are so... bleh they just make you feel confused on the spot. Others make you feel like you understand because they don't tell you the whole story. You, sir, are neither. You are an awesome teacher. Thanks! 😅

  • @matitiudeforever8155
    @matitiudeforever81556 жыл бұрын

    thank you for all of your lectures !! may god bless you and you find happiness in your life

  • @kinmokuseikaori11
    @kinmokuseikaori112 жыл бұрын

    This is a billion times better than anything I have seen thus far. Simply amazing!

  • @AbhishekSingh-tz3uv
    @AbhishekSingh-tz3uv3 жыл бұрын

    I liked this video series very-very much. Got to learn a lot of new things. Hope to see more of such wonderful content on your channel. Thanks Corey!

  • @meenumeric
    @meenumeric5 жыл бұрын

    I first press like button before watching your videos. Awesome work!

  • @Jonathan-rm6kt
    @Jonathan-rm6kt5 жыл бұрын

    Best python videos ive found, keep em coming. Im coming from an analyst background so am more used to performing examples like these with database operations. Can anyone pls describe other common use cases for attribute setting?

  • @boopmcbloop8648
    @boopmcbloop86482 жыл бұрын

    Thank you so much Corey! I'm so glad I discovered your channel. I want to go into data analytics and I'm happy to see all the video series you've made about Python libraries. I'm looking forward to watching more of your tutorials :)

  • @romanleca4969
    @romanleca49694 жыл бұрын

    I would kill to have had this kind of teacher back in the university days :) Thank you for the fantastic work, Corey.

  • @Mrjarnould
    @Mrjarnould8 жыл бұрын

    Great video!

  • @LadyPary8
    @LadyPary84 жыл бұрын

    I love how you explain everything so simple and clear! I watched this whole tutorial! Thank you so much! Be safe.❤️ Ps. Your really good voice makes this learning process a lot better and easier :)

  • @coreyms

    @coreyms

    4 жыл бұрын

    Thanks!

  • @KOtwenyo
    @KOtwenyo7 жыл бұрын

    I must say, I am learning from you more than I did from an MOOC that teaches the same Python, thank you Corey

  • @aoiwoi
    @aoiwoi7 жыл бұрын

    This is the best python tutorial ever. I am so happy to find the channel.

  • @franklinbradfield9131
    @franklinbradfield91316 жыл бұрын

    So much more useful than the Python docs that use "foo", "bar", and "x" for everything!

  • @zes7215

    @zes7215

    5 жыл бұрын

    no such thing as need

  • @NaachoElegante
    @NaachoElegante5 жыл бұрын

    really appreciate your skills and talent of explaining...............loved everything about your videos...........be it voice, language, content, explanation, concept...........too good..............would request you to make some videos on data structures with python

  • @stephenrogers5458
    @stephenrogers54584 жыл бұрын

    I'm a software developer refreshing my skills to include Python and JS (from a base of having done a lot of C#). I find your pace and style perfect for doing this as quickly as possible. I am able to incorporate what I'm learning into actual ground up product dev coding as I go through your short tutorial format. Looking forward to seeing other videos you've created. Thanks for the great work.

  • @ordinaryBrain4300
    @ordinaryBrain4300Ай бұрын

    I am in disbelief that I came here because my paid course confused me. This tutorial is far better. Thanks a tonne! ❤

  • @ManishKumar-hv8hg
    @ManishKumar-hv8hg4 жыл бұрын

    Please sir, like this, make a tutorial on "Data Structures using python" like; linked list, stack, queue, tree and graph

  • @iremkaya9103
    @iremkaya91036 жыл бұрын

    Why haven't I found you sooner, I would have done a lot better in lab classes of Python :(( You are great!

  • @adetolasanni007
    @adetolasanni007 Жыл бұрын

    I just finished your playlist. Before now I was totally confused of OOP but watching this video gives me a fresh start. Thank you.

  • @spiritualquest6092
    @spiritualquest60926 жыл бұрын

    One of the excellent tutorials on Python, great demo!

  • @need2game834
    @need2game8345 жыл бұрын

    I like how the first video has over 1 million views and the last one 226k :D for me I watched the whole series and it was excellent, thanks Corey

  • @mujahidrasheed4987
    @mujahidrasheed49877 жыл бұрын

    Great post.. For PYthon 2: the Class must inherit from the 'object' class to able able to use decorators. example: class Employee(object) learnt it the hard way..

  • @mujahidrasheed4987

    @mujahidrasheed4987

    7 жыл бұрын

    Wanted to ask,, are there more vids coming up on OOP or this was it?? Thanks COrey

  • @coreyms

    @coreyms

    7 жыл бұрын

    Hi Mujahid. These 6 videos were the ones I really wanted to get done. Now that they are finished I am focusing on some different video. I do think I'm going to add to this series later on, but have no immediate videos in the works. I did want to finish some videos on Multiple Inheritance and Abstract Base Classes, so when I do those videos, I will likely add them to this series. Thanks

  • @zorkan111

    @zorkan111

    7 жыл бұрын

    Mujahid, thanks for the tip. I'm using Python 2 and I was wondering why my code didn't work the way it did on the video. Any explanation as to why the class has to inherit from 'object'?

  • @indirajithv5041

    @indirajithv5041

    7 жыл бұрын

    Just read this comment. Looking forward to learning from coming tutorials! Thank you very much.

  • @susannaventafridda430

    @susannaventafridda430

    6 жыл бұрын

    Hey Mujahid, I am also using Python 2 and when I try emp_1.fullname="Corey Schafer" (min. 6:40 and line 25 in the video) it gives me this error: TypeError: 'str' object is not callable. I have, like you, written class Employee(object):... but I really can't solve this problem. How did you do it? Thanks!

  • @hichamamchtkou7343
    @hichamamchtkou73434 жыл бұрын

    Men, they should give you like a nobel prize about what you have done not only in this tutorial but in your KZread channel , you're like superman for Python developers, thank you very much!

  • @timo_b3
    @timo_b32 жыл бұрын

    I watched many other videos about this topic, but this series is by far the best one to learn oop python. thank you corey!

  • @Pkmafffy
    @Pkmafffy6 жыл бұрын

    Amazing series on OOP - I learnt so much! One thing I don't quite understand is when to leave your attributes as public or using '_' (underscore) notation to privatise them. When playing around with the underscore notation I sometimes get 'maximum recursion errors'. I know this isn't covered in this series, but I would really appreciate it if you knew of any resources to better understand this. Thanks

  • @kaushaltak007

    @kaushaltak007

    4 жыл бұрын

    Maybe it's late but you can check this link out www.python-course.eu/python3_class_and_instance_attributes.php

  • @swadhikarc7858
    @swadhikarc78587 жыл бұрын

    Hi Corey, Your videos are none other than best! Simple and easy to understand. I am a beginner to Python and have a question in deleter. The example you have shown is used to delete a property. Can you explain how to delete an instance itself? example: del emp_1? Thanks a lot for your videos!

  • @coreyms

    @coreyms

    7 жыл бұрын

    Hey there. If you wanted to delete the instance and completely remove the binding of emp_1 from the namespace, then yes, you could just say: del emp_1

  • @dragost8670

    @dragost8670

    6 жыл бұрын

    Hi, Corey. Just tried to use del for an instance but the second one was deleted either. Here is the code: class Robot: def __init__(self, name): self.name = name def say_hi(self): print('The robot ', self.name, ' says hello!' ) def __del__ (self): print('The robot ', self.name, ' was destroyed! :((') if __name__ == '__main__': x = Robot(input('the name of the first robot, please:')) y = Robot(input('the name of the second robot, please:')) for i in [x, y]: i.say_hi() print('deleting first robot') del x print("we'll not destroy any robot anymore! :)") y.say_hi() # after running this code, y instance is also deleted. I really don't understand why... Kindly please help on this. Thanks in advance!

  • @PiddBoo

    @PiddBoo

    6 жыл бұрын

    Your question is already 3 months old, therefore i don't know if this is helpful to you: but your code works just fine. I had to change the "if _name_ == '__main__'" to "if __name__ == '__main__'" because it was causing a name error. But other than that the output is as expected.

  • @riturajsminivlogs

    @riturajsminivlogs

    6 жыл бұрын

    if True: x = Robot(input('the name of the first robot, please:')) y = Robot(input('the name of the second robot, please:')) for i in [x, y]: i.say_hi() print('deleting first robot') del x break print("we'll not destroy any robot anymore! :)") y.say_hi()

  • @antondjayzakov4776
    @antondjayzakov47763 жыл бұрын

    Learning in a big rush. Everything clearly explained. Thank you Corey

  • @esthers5201
    @esthers52018 ай бұрын

    I went through about 5 videos trying to understand why we need property decorators....your video was the only one that explained it in a clear and concise manner!!

  • @soumitripattnaik
    @soumitripattnaik6 жыл бұрын

    At 5:54 can't we simply do self.first, self.last = name.split(' ') ?? It's been a great learning experience from your videos :)

  • @coreyms

    @coreyms

    6 жыл бұрын

    Yes

  • @h82fail

    @h82fail

    6 жыл бұрын

    Was thinking the same thing and was getting ready to type it out to test myself, good to know it will work.

  • @karthik-ex4dm

    @karthik-ex4dm

    5 жыл бұрын

    Good one!

  • @kamranshirazi3030

    @kamranshirazi3030

    2 жыл бұрын

    Sure, good observation. But as a teaching method, I think, it was more artistic to have a uniform format as the class's __init__ the way he did it, that is also better for people who are learning it.

  • @johnhendy1281
    @johnhendy12817 жыл бұрын

    This has been an amazing series! I've taken some Coursera classes, but always felt overwhelmed when I saw classes and the dreaded __foo__ and `self` stuff start showing up. Thanks so much for making these! One question... is there a reason not to do: `self.first, self.last = name.split(' ')` when you define the fullname.setter? Perhaps expanding is more readable? Quick edit: I did this, and it seems to work fine. I mainly wondered if it's considered more pythonic to do one vs. the other.

  • @powerblender

    @powerblender

    7 жыл бұрын

    I think you can do that.. but using self.first = first and self.last = last makes the code more readable, I think.

  • @silverzero9524

    @silverzero9524

    6 жыл бұрын

    maybe he forgot lol

  • @sbarter

    @sbarter

    6 жыл бұрын

    self.first, self.last = name.split(' ') creates a list. i'm guessing here but it probably slows down the code.

  • @darkaero

    @darkaero

    6 жыл бұрын

    I think he did it that way to be able to explain step by step what was going on when you're using the split() to separate the full name and how using the self.first and self.last gets it to work again.

  • @manishbagra9494

    @manishbagra9494

    6 жыл бұрын

    he did it to make it more clear but you can also do like " self.first, self.last = name.split(' ') "

  • @christophermichaelrytting5465
    @christophermichaelrytting54655 жыл бұрын

    Property decorators are not that hard to explain, and you seem to be the only person on the internet who realizes that! Thanks much.

  • @anushapai6777
    @anushapai67772 жыл бұрын

    Exactly, what I was looking for. To the the point and super clear with example.

  • @anon-sl4vp
    @anon-sl4vp5 жыл бұрын

    print('Love learning with Corey Schafer xD')

  • @imranayari
    @imranayari3 жыл бұрын

    You can as well password protect the changes that can be applied to the property decorator, for instance, on deleter implementation: @fullname.deleter def fullname(self): password = input('Please enter password: ') if password == 'pass': print('The fullname ' +self.first +' ' +self.last +' is deleted') self.first = None self.last = None else: print('Invalid password')

  • @MODDINGPRIME

    @MODDINGPRIME

    3 жыл бұрын

    Very useful! Thanks for this :D

  • @DragonRazor9283

    @DragonRazor9283

    3 жыл бұрын

    Is there a smart way to obscure the "if password == 'pass'" statement so that others won't just look at the source code that easily?

  • @eldadizhaky

    @eldadizhaky

    3 жыл бұрын

    @@DragonRazor9283 You can use a hash function on your password, and when the user inputs a password, use the same function and compare the hashes.

  • @wildmanofhk

    @wildmanofhk

    3 жыл бұрын

    Good stuff

  • @vanchark

    @vanchark

    2 жыл бұрын

    @@DragonRazor9283 You can use the bcrypt python module for that. Example: import bcrypt # pip install bcrypt pw = "test_password" salt = becrypt.gensalt() # salt is a random value that gets added to every hash to ensure it's unique hashed_pw = bcrypt.hashpw(pw, salt) # generate hash if bcrypt.checkpw(pw, hashed_pw): # compare hashes # success --> do something else: print("invalid password")

  • @whjeng
    @whjeng5 жыл бұрын

    This is an excellent explanation for property in very concise way. Thanks Corey.

  • @johntank3004
    @johntank30043 жыл бұрын

    This would a good example how to deal with someone switching their last name because of marriage or someone having a full name change.

  • @manulgoyal6662
    @manulgoyal66625 жыл бұрын

    30 semicolons disliked the video

  • @Charlie-lf7iy

    @Charlie-lf7iy

    4 жыл бұрын

    Nice one!

  • @PersianPoemPulse

    @PersianPoemPulse

    4 жыл бұрын

    forgotten semicolons actually :)

  • @thengakola6217

    @thengakola6217

    3 жыл бұрын

    30 what?

  • @avenger_aawin4971

    @avenger_aawin4971

    3 жыл бұрын

    @@thengakola6217 java coders

  • @wexwexexort

    @wexwexexort

    3 жыл бұрын

    as a semicolon I dislike this comment not the video, lol =p

  • @ABC-xn3td
    @ABC-xn3td7 жыл бұрын

    Great tutorial Corey. I learnt a lot of new things that I did not know existed in Python.

  • @sreekanththota2200
    @sreekanththota22004 жыл бұрын

    I just now compleated all ur OOP concepts,it took 2days for me......finally feeling happy......Tqs for osm explanation.....

  • @sep69
    @sep693 жыл бұрын

    Thanks you very much for the OOP tutorial series. I was already using classes but still learned a lot from your videos. Big thanks again :)

  • @gevillgar
    @gevillgar2 жыл бұрын

    Your explanation is like a very optimized code. It serves its purpose with the minimum amount of examples and words needed to make the concept clear.

  • @thekeyfox
    @thekeyfox Жыл бұрын

    Excellent playlist, Corey! I'm sad there aren't more videos but these did help my understanding of classes a lot! Thank you!

  • @SaruwatariMasahiro
    @SaruwatariMasahiro2 жыл бұрын

    Thank you for your OOP series. I'm just getting started with python but I learned a lot from just this series.

  • @tanselervansel1648
    @tanselervansel16484 жыл бұрын

    The Best Teacher in Phyton so far. Thanks for your education.

  • @qbmain1487
    @qbmain14874 жыл бұрын

    Amazing example that really shows the need of these methods

  • @hermesdhenares6893
    @hermesdhenares68934 жыл бұрын

    I made a Python course some months ago: paid too much for too little; I began the Treehouse Python Track: too many conceptual holes, some topics barely explained. You just filled each and every one of those holes, Corey. Your vids are fantastic!

  • @jonathanbush5915
    @jonathanbush59152 жыл бұрын

    I watched all 6 videos on OOP and you have officially helped me learn these concepts. Thank you and I will subscribe !

  • @saurabhkansal8178
    @saurabhkansal81787 жыл бұрын

    Before starting these videos, I don't have any knowledge of classes. But now i got the concept and can understand the source codes in better way. Thanks Corey... Thanks a lot..

  • @ArjunKG95
    @ArjunKG955 жыл бұрын

    I've read about @property in so many places. But understood it properly for the first time here. Amazing video!

  • @Nuhyamin1

    @Nuhyamin1

    5 жыл бұрын

    I still don't understand it, help me please

Келесі