V
V
Vadim2022-01-06 02:37:53
Python
Vadim, 2022-01-06 02:37:53

Can a python class have two parents?

Hello everyone,

I apologize for the stupid question, but what is the difference between these two classes:

1)

class DirectionName(str, Enum):
    north = "North"
    south = "South"
    east = "East"
    west = "West"


2)
class DirectionName(Enum):
    north = "North"
    south = "South"
    east = "East"
    west = "West"


like not one of them when calling for example the function
def get_directions(direction_name: DirectionName):
if direction_name == DirectionName.north:
print(direction_name)

does not give an error!

All the best,
Vadim

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2022-01-06
@Viji

Can a python class have two parents?

may
what is the difference between these two classes

the fact that one is inherited from two classes, the second from one (c) Your cap
like not one of them, for example,
does not give an error when calling a function!

Why should you give?
If the function used some methods of the str class, it would give.

K
Kadabrov, 2022-01-06
@Kadabrov

Learn to use fishing rods (search, tutorials, videos on YouTube), since there are plenty of them, you ask a question that you must learn yourself, these are the basics of the language

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question