#๐ we live in a society
24 messages ยท Page 1 of 1 (latest)
@leaden nest
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Item is an abstract base class. You can't instantiate it.
if you want Item to be instantiable, don't use ABCs
It should just be a normal class
Nothing, it's a class meant to be inherited from
Or, if you don't want Item to be instantiable, replace the body of use with ... because there shouldn't be a default for it since it's abstract
because it's not an ABC
print("Used regular item.")
Because use is an abstractmethod. Abstractmethods require that you implement them in classes that inherit from it
You can either have a default class - a normal class with no abstract stuff, or an abstract class - which is just an interface and requires that inheriting classes implement the methods
Abstract classes are not instantiable
yes but that's really not how it's meant to be used.
if you got an abstract base class, that has abstractmethods... any subclass is required to implement all abstract methods.
The whole point of ABCs is this enforcement.
I don't think you want an ABC or an abstractmethod
because defaults are kind of useless in this case
and you'd really never need to make an Item that has nothing about it
... does nothing there. I was suggesting that you replace the print statement with ..., but only if you were going to keep the class abstract
... = pass, by the way
So, do you want to be able to make a default Item or not?
because currently you can just remove the @abstractmethod decorator if you want to be able to inherit that default use
and then you don't need to define it in OtherItem
But, again, instantiating a plain Item doesn't make sense, so that's probably why Robin suggested making an AbstractBaseClass
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.