On Tue, 6 Oct 2020 at 15:33, Alperen Keleş <alpkele...@gmail.com> wrote:
> Cars have different states, MovingCar, IdleCar, ParkingCar...

Well, IMHO the solution is quite more simple:

class Car:
    def __init__(self):
        self.state = "parking"

    def move(self):
        if self.state != "moving":
            raise StateException("car can't move!")

        [...]
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/5P2WVGDX6HFUY2JMKJZ7OQP5YGJ5F6PL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to