How To Use: '@abstractmethod' In Python (Tutorial 2023)

preview_player
Показать описание
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:

▶ Follow me on Instagram:
Рекомендации по теме
Комментарии
Автор

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!

EddiKh
Автор

Bro, U shouldn't use "..." for ABC class methods, as I know for ABC U should use "pass", "..." its reserved for Protocols

jamesford
Автор

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

davidl
Автор

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?

garikisrayelyan
Автор

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.

eldebtor
Автор

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

henrijohansson
Автор

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?

joxa
Автор

Isn't iBanana.__init__ and the super() call redundant code?

derekreed
Автор

maybe mention that abstractproperty and abstractstaticmethod are deprecated.

DrDeuteron