bestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 2か月前The meaning of thislemmy.mlimagemessage-square72fedilinkarrow-up1540arrow-down114
arrow-up1526arrow-down1imageThe meaning of thislemmy.mlbestelbus22@lemmy.world to Programmer Humor@lemmy.mlEnglish · 2か月前message-square72fedilink
minus-squareSjmarf@sh.itjust.workslinkfedilinkEnglisharrow-up18arrow-down2·2か月前Python does have a switch statement now, actually. And yes, they went out of their way to call it something different - match. https://docs.python.org/3/tutorial/controlflow.html#match-statements
minus-squareNichtElias@sh.itjust.workslinkfedilinkarrow-up11·2か月前match isn’t just equivalent to switch though, so in this case it actually makes sense to call it something different.
minus-squareArchr@lemmy.worldlinkfedilinkarrow-up1·2か月前This is very true. Match statements are much more powerful that switch statements in any other language. For instance: matching objects very specifically if conditions within case statements pulling variables from inside of the object directly.
Python does have a
switch
statement now, actually. And yes, they went out of their way to call it something different -match
.https://docs.python.org/3/tutorial/controlflow.html#match-statements
match
isn’t just equivalent toswitch
though, so in this case it actually makes sense to call it something different.This is very true. Match statements are much more powerful that switch statements in any other language.
For instance: