Encapsulation - Advanced Python Tutorial #5

preview_player
Показать описание
In this video we talk about encapsulation in Python.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

💻 Exclusive Content 💻

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

1. no, double-underscore does not mean 'private'. There is no concept of 'private' in Python. You should have used _name, age, gender.
What you did was name-mangling, which only means it is slightly harder to access the variables.
2. Do not use Capitals for methodnames (pep-8). No idea where you picked up that its a 'convention', but it isn't. Only capital for Class names (not objects).
3. You are using @staticmethod incorrectly. It should be outside of the class, because it is already in the module, so no issue with collisions. What you probably want is a @classmethod. There is no real use case for @staticmethod and according to Guido "it was somewhat of a mistake".

alexd
Автор

Great way of explaining Encapsulation in Python. I would add though that real Encapsulation is not a thing in python, since you have access to __private variables through object's __dict__ / class's __dict__, unlike other languages where private is really private. This seems to me an important feature that people should know about. Maybe a subject for another video 🤗 ?!?

tibish
Автор

This couldnt have arrived at a better time. Thank you for this man keep it up!

iiStxrii
Автор

wow, made me realize i need to finesse my python oop skills, thank u!!

julietatallaferro
Автор

Your content is A+, your presentation is A+, your Editing is A+, your keyboard is F! Its sound drives me crazy

ghadeershaaya
Автор

One of the best instructor... Love You Sir❤️❤️..
If possible please upload advance pandas

rahulpagar
Автор

I would have to say that using self.__param = param in the __init__ method is not the best option if you need to validate the param. The flaw is that when first instantiating the class, the param doesn't go through validation. I would say it's better to use self.param = param, and then the setters and getters will return self._param. When the __init__ method runs self.param = param, it will run the internal setter thus using the validation when instantiating the obj.

anaadrian
Автор

Always breaking the league bro ..good job!

felixfigueroa
Автор

Nice video, I really enjoy your videos and there are simple to understand!
By the way what's your opinion for encapsulation in python?
Since it really feels like there isn't a language capable of doing something like that efficiently.
For an example you can easily bypass the setter method and store "Bob" as name with ```p1._Person__name = "Bob"```.
Anyway keep up the good work!!!
Edit: Forgot to request for a video about threading/multiprocessing!
Do you have plans for it in the near future?

GodotEnjoyer
Автор

This is a great advanced series. Very helpful.

StephenEhrlichPhotos
Автор

In case of example, even if you do not have @property then you can still use p1.Name() instead p1.Name

hovardlee
Автор

so should you always use getter and setters where you can on yout code?

bjorncalbes
Автор

What terminal are you using?

Nice nvim setup btw

inx
Автор

Nice!!!
Please suggest best language to create gui apps, tkinter is way too slow

zombiekiller
Автор

Hey! Which IDE are you using in the video?

MananGandhi
Автор

Can you explain vim editor and how to use it

cybersecurity
Автор

Does the same apply to protected attributes?

rafaeel
Автор

I believe it is possible to set the __ attribute by using their mangled name. Thank you

amitshogun
Автор

you just called Bob basic ahh bih lmao

gotitboom
Автор

Can you make video about creating WAF with python?

guga
join shbcf.ru