How To Use: "@abstractmethod" In Python (Tutorial 2023)
HTML-код
- Опубликовано: 4 июн 2024
- Python's @abstractmethod is actually really useful. It helps us keep our code more consistent in certain situations. So let's learn more about it in this Python tutorial!
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
that moment when you google a topic and you see Indently has a video on it, you know you will understand it quick and easy... many thanks!
Bro, U shouldn't use "..." for ABC class methods, as I know for ABC U should use "pass", "..." its reserved for Protocols
great video thank you
Nicely explained
Excellent thank you. I was looking for that ;) It is the same as Interface in java. You don't herite from, you have to implement them. But the process is the same. Very usefull
Hi, isn't that the 'protocol' that is somewhat like 'interface'?
@@Geza_Molnar_ yes also, .but Principles are thé same. You create an object with empty methods that need to bé filled if you want to use this object
Is it correct to use ABC in Django? For example I create a model that I want to be abstract, can I inherit ABC into it so that it becomes impossible to create instances out of it?
abstract classes exists in java but python lacks oop sophistication as it has no access modifiers for classes or class attributes or inheritance specifiers as in this case.
Interesting, missed on the fact that the @property notation doesn't cause the function to work like a property in the class that implements the abstract. You actually had to implement the function, but the @property stays there.
Wait there is more, they occupy the same name space as the properties themselves, but use entirely different syntax. Fascinating
I wonder can I just implement them with the @property notation as they are
Why do we use Abstract class for?
to be a dick to your fellow programmers
maybe mention that abstractproperty and abstractstaticmethod are deprecated.
what ide are you using
Thats VS Code afaik
@@youngsterdan lol its pycharm
No it's pycharm
I read a lot on Google about abstraction in Python. Most of it stated that the objective is to hide the information and complexity from the user.
But I can'r understand and see which part exactly is the "HIDING" part. Can anyone explain this?
The user doesn't need to understand how your code works internally (meaning every line), they just need to know how to use your public classes. Those public classes are abstractions of your private classes that makes the code function.That's my interpretation. Please correct me if I'm wrong or missing something.
Hahah , ibanana like iapple
Bro get the camera I'm verified
Bro, you know I can't afford a camera.
Greatest collab in history and nobody's paying attention
First