#๐Ÿ”’ we live in a society

24 messages ยท Page 1 of 1 (latest)

grizzled wigeonBOT
#

@leaden nest

Python help channel opened

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.

thin bronze
#

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

sand rivet
#

Nothing, it's a class meant to be inherited from

thin bronze
#

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.

hoary geyser
#

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.

thin bronze
#

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?

thin bronze
#

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

grizzled wigeonBOT
#
Python help channel closed

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.