#i’m a beginner, bt want to try & prevent myself from making spaghetti code..
15 messages · Page 1 of 1 (latest)
Do you mean, like how is it implemented, or how does one use it?
both, i suppose..
Are you familiar with switch cases in other languages?
can’t say i am
action = input("input action")
if action == "open":
...
elif action == "close":
...
elif action == "move":
...
elif action == ...:
...
So, the match statement would make writing this a bit easier.
i see..
I can write a bit more, just need to craft the example.
action = input("input action: ")
match action:
case "open":
...
case "close":
...
case ...
So this is just something really basic, but match is a lot more powerful than this.
If you're comfortable reading Python, then this PEP I think does a great job showing all of the neat features.
Python Enhancement Proposals (PEPs)
ty!!
I think the examples are pretty self contained and approachable, if you have questions about them, don't hesitate to ask.