I think a better fix to this bug is to say that (0, y) is a vertical-intercept (or y-intercept) and (x, 0) is a horizontal-intercept (or x-intercept). This is because for a line to be drawn, two points on said line are needed. Since we are only analysing one point at a time, it is most accurate to say that it is an intercept of either axes, provided that either x == 0 or y == 0.
MISTAKE IN THIS VIDEO You don't NEED to use an underscore. You can AND SHOULD use any valid variable name to capture the value for later use, such as if you want to include the value in a raised error. The reason the underscore is used is that sometimes you will not need to access that variable after capturing it and in python tools (flake8, pylint, pylance, mypy), the underscore doesn't raise a warning if the variable is never accessed as any other variable name will.
Use an underscore if you DO NOT need to access the matched object in the case code block. Otherwise use a meaningfully-named variable to access the value inside the case code block.
ohh What a nice video it is! Thanks for every information. match and switch statements are more useful than if and else. We can already use these instead of those and it prevent to repeat the same things. Now we just need to use one of them(match and switch) and It is the easier way to make code in Python in my opinion.
I hope Python 3.15 will be Python 4 to maintain the row of natural constants found in the last releases a python version. Golden ratio: 1.6.1 e: 2.7.18 pi: 3.14.x
Nice video, can I use the "match" & "case" statements at one line like the "if" one, also I am not sure why did they add these while we can simply do almost most of it using the "if" statement and get the same result ..
Wile it’s always been possible to create match statement equivalents, a real switch/case mechanism is something Python has been lacking. Considering how many other features it has, it is strange that it’s taken this long to add it to the language
I read somewhere that this has to do with the python philosophy, it's not that they can't, it wasn't considered necesary since if elif else does roughly the same thing, however pattern matching imo is way cleaner and I'm happy to see it being added, also the whole "doesn't fit the python philosophy" I just read it somewhere, I have 0 trustable sources so I would appreciate it if someone proves/disproves me
The one feature I thought python lacked and now we have it. I've not been this excited about a new version of a language since VB4 came out. Honestly I'm hyped over the new "match" statement.
it's not switch statement, it's pattern matching, it used a lot in functional style programming. Is that good for python? I don't think so, it just add another layer of complexity but the community that run the language don't care about that anymore...
@@ericks4774 It will train people to use recursion, because pattern matching is usually used with recursion and python is very slow at recursion. it's add a new way of doing the exact same thing that break python phisolophy to keep things simple. Otherwise I really like the feature
This is fantastic. I'm now very excited for 3.10. But ... as you don't put break in, I'm guessing there is no way to fall through? Perhaps with pattern matching it's not really necessary to fall through. Hmmm, need to spend some time with this. Great video!!
In the example where you used case (x, y) if x == y: couldn’t you have done case (x, x)? i think that works in pattern matchers such as ocaml’s one, but not sure about this one! thank tou
I feel like this would greatly simplify writing an interpreter or compiler and pretty much remove the need for regex. Can match statements be nested? Edit: yes they can!
I personally wouldn't call it powerful because (at least for the examples you brought up) we do everything with if statements without increasing line count or unreadability too much :) There's probably a case where the if statement would take 10 lines and this one 2, but that's highly complex code anyway I guess, so it doesn't matter that much :)
Could you please make an in depth tutorial on how to make a leaky bucket in python? I look at source code for other people’s, but I can’t understand it. I want to make a rate limiter for my API
lol you can just use the math symbols on integers: fn = input("Enter the first number: ") sn = input("Enter the second number: ") result = fn + sn print(f"The Result is: {result}")
@@electricz3045 I mean rather than having two inputs and a hardcoded "+" you simply type "1+2" in a single input statement. And don't forget other operations and the order of operation. For example: "2+4*5+(4/2)". The output should be 24.
@sa9097 Yeah I mean you could do that, but still. Doesn't that remove the whole meaning of the project. And what if he/she wants to type X instead of *?(You could of course just do .replace("X", "*")) I think you get my point it is a good/difficult project for beginners.
@@elishashmalo3731 its version numbers, not maths rounding or significant figures do not come into play. seriously did you start rounding up to python 4 when you switched to python 3.5? i sure doubt it
I came from zero to...i am pretty good right now. Coming from a third world country, the programming taught in school is just so bad(sorry). I made my school projects from what I'd learned from you. Thank you so much. Definitely told my friends about this channel
I think try-except is used to catch errors, not for regular pattern-matching. It looks similar because it does a similar thing, but try-except for a start needs some actual errors to go into the except block - meaning you would need to write the matching in a way, that produces an actual error. The original if-elif-else chains this will replace would need conditions that produce True/False. Meanwhile Match-Case just needs patterns and it will do the comparison for you. No need for conditions, no need for forcing errors.
Whats the point of this... Couldn't you just make a dictonary of values and get the case from that? Example: values = {"x": "This is x"} my_case = "x" value = values.get(my_case) print(value)
Dictionaries need non-mutable objects as keys and cannot match wildcards either. So no, it's not the same. It's also not the same in other languages, as the "break" keyword indicated in the beginning - because switch-case would execute all cases after the first true one. Hence the need to include "break" so it doesn't do that. This can technically be used to combine some cases.
@@rylandavis2976 Oh, really? Civ 4 made in Python btw... and people still play it ( including myself ) they made CyberPink 2077 in C# and took them more than 8 years and then... they screwed everything... waste of time resources...
@@SkyFly19853 civ 4 is not written in python. Certain parts are. Almost all of the underhood stuff is written in a more technical language because of needs to manage performance and resources. Civ 4 allows python scripting tho
I think the case(0, y) makes horizontal line with y provided, not a vertical, and vice versa.
Good catch!
I think a better fix to this bug is to say that (0, y) is a vertical-intercept (or y-intercept) and (x, 0) is a horizontal-intercept (or x-intercept). This is because for a line to be drawn, two points on said line are needed. Since we are only analysing one point at a time, it is most accurate to say that it is an intercept of either axes, provided that either x == 0 or y == 0.
algebra
Which axis is the x-axis? Horizontal or vertical?
@@donh9135 horizontal
Finally it would be easy and less chaotic to make command line programs.
I was fascinated that Python avoided a switch statement and now I see this and think, "It was worth the wait". This is great and extremely flexible.
MISTAKE IN THIS VIDEO
You don't NEED to use an underscore. You can AND SHOULD use any valid variable name to capture the value for later use, such as if you want to include the value in a raised error.
The reason the underscore is used is that sometimes you will not need to access that variable after capturing it and in python tools (flake8, pylint, pylance, mypy), the underscore doesn't raise a warning if the variable is never accessed as any other variable name will.
As in, when none of the variables are used again in case _ , x means _ and x can be the same?
Use an underscore if you DO NOT need to access the matched object in the case code block. Otherwise use a meaningfully-named variable to access the value inside the case code block.
You only should use a variable if you need to use the value, otherwise use an underscore.
Finally! I've been missing switch statements in Python
me2. I can't wait to update the if-elif cascades to match.
Congrats python for improving on an old concept in a new and innovative way! It was worth the wait for the switch statement to see this!
basically an alternative to the if,elif and else statement?
ohh What a nice video it is! Thanks for every information. match and switch statements are more useful than if and else. We can already use these instead of those and it prevent to repeat the same things. Now we just need to use one of them(match and switch) and It is the easier way to make code in Python in my opinion.
as a java programmer that uses switch statements all the time. i am very excited.
Will python 4 be a thing?
I dont think in near future because 3.10 is valid until 2025 and 3.11 is in development already.
Guido van Rossum said that if there ever will be Python 4, the transition from 3 to 4 is gonna be smoother than that of 2 to 3
Sure, there would be a python 4, but we would have to wait for that.
@@GainTheReason No I think they will release a new version of Python but It is enough up to 2022 or 2023.
I hope Python 3.15 will be Python 4 to maintain the row of natural constants found in the last releases a python version.
Golden ratio: 1.6.1
e: 2.7.18
pi: 3.14.x
union and algebraic data types are cool as hell
Nice video, can I use the "match" & "case" statements at one line like the "if" one, also I am not sure why did they add these while we can simply do almost most of it using the "if" statement and get the same result ..
Wile it’s always been possible to create match statement equivalents, a real switch/case mechanism is something Python has been lacking. Considering how many other features it has, it is strange that it’s taken this long to add it to the language
I read somewhere that this has to do with the python philosophy, it's not that they can't, it wasn't considered necesary since if elif else does roughly the same thing, however pattern matching imo is way cleaner and I'm happy to see it being added, also the whole "doesn't fit the python philosophy" I just read it somewhere, I have 0 trustable sources so I would appreciate it if someone proves/disproves me
I have to say that I wasn't sure that I expected it to be anything hype, but damn - I will probably upgrade right away just to get this feature :D
This is "select case" like in other languages, but maybe more powerful.
Great job Tim!
it's just like He Did developed Python 3.10 version
The one feature I thought python lacked and now we have it. I've not been this excited about a new version of a language since VB4 came out.
Honestly I'm hyped over the new "match" statement.
feels like Haskell
I've just started to learn JavaScript and was wondering why python did not have a switch statement... amazing video/explanation, thank you!
it's not switch statement, it's pattern matching, it used a lot in functional style programming.
Is that good for python? I don't think so, it just add another layer of complexity but the community that run the language don't care about that anymore...
@@TechWithVince I don't see the wrong there, why is bad to add an optional feature that makes the language more completed
@@ericks4774 It will train people to use recursion, because pattern matching is usually used with recursion and python is very slow at recursion.
it's add a new way of doing the exact same thing that break python phisolophy to keep things simple.
Otherwise I really like the feature
I love the way you explain, thank you.
This is really powerful stuff specially when we integrate *args and **kwargs, def gonna use the heck out of it
Thanks Tim really helpful 👍 🙏
This is fantastic. I'm now very excited for 3.10. But ... as you don't put break in, I'm guessing there is no way to fall through? Perhaps with pattern matching it's not really necessary to fall through. Hmmm, need to spend some time with this. Great video!!
The underscore is just convention to say that you don’t care about the value of a variable.
In the example where you used case (x, y) if x == y:
couldn’t you have done case (x, x)?
i think that works in pattern matchers such as ocaml’s one, but not sure about this one!
thank tou
Just a few hours ago I finished all the series and then there were none left and a few hours later there it is! Thankyou so much Tim!
Nice, feels like Elixir
Hello everybody and welcome ... Your intro is the best! And content too :)
I feel like this would greatly simplify writing an interpreter or compiler and pretty much remove the need for regex. Can match statements be nested?
Edit: yes they can!
What's the difference between the match: case statement and simple if, if else??
prolly, to be like other programming languages lmao
but tbh it looks cleaner like this ig!
Cool features , python💪💥💥...
Your awesome man. Keep the good work up
I personally wouldn't call it powerful because (at least for the examples you brought up) we do everything with if statements without increasing line count or unreadability too much :)
There's probably a case where the if statement would take 10 lines and this one 2, but that's highly complex code anyway I guess, so it doesn't matter that much :)
🤣I agree with you
This is awesome !!
I’m a regular viewer of this channel. Didn’t expect to be the first to post a comment. Great tutorial s always!
Is there no way to make all cases get checked? The equivalent of turning each match from an "elif" to a "if"
What text editor are you using?
Yeah I like this. thanks tim
Thanks Tim. Nice :-)
Your example_two program doesn't work properly. It would print valid coords for input like ("a", "b")
What keyboard do you use now?
I normally agree with the python org but I really don't like how this writes. But even if it's ugly it's actually really usefull
Could you please make an in depth tutorial on how to make a leaky bucket in python? I look at source code for other people’s, but I can’t understand it. I want to make a rate limiter for my API
I am still busy in building my first calculator in python (I learnt the basics around 2 months back)
lol you can just use the math symbols on integers:
fn = input("Enter the first number: ")
sn = input("Enter the second number: ")
result = fn + sn
print(f"The Result is: {result}")
@@electricz3045 What if he/she wants to have an input like "1+2"? Then the project becomes more complex.
@@cozycode8586 no? You run the script and then input the numbers you want to calculate
@@electricz3045 I mean rather than having two inputs and a hardcoded "+" you simply type "1+2" in a single input statement. And don't forget other operations and the order of operation. For example: "2+4*5+(4/2)". The output should be 24.
@sa9097 Yeah I mean you could do that, but still. Doesn't that remove the whole meaning of the project. And what if he/she wants to type X instead of *?(You could of course just do .replace("X", "*")) I think you get my point it is a good/difficult project for beginners.
Much awaited feature in python !
You will never gonna give you up!
That's sick !
Hi Tim. Live the videos
You're the best, can u make an angular course ! 😘
what about cases without "break"?
Jump to 2:20
Similar to rust match statement
I think this is the first time you are adding background music to a video...
Awesome
Why not just use if and elif?
What if I have a variable named _ ?
variables get overwritten...
you could also ask: "what if i have a variable x?"
Please make a course about python in cyber security and ethical hacking 🥀🙏
wow this is so powerful !
Much easier way to create voice assistants!
Reminds me of how you code in Prolog.
Please make a flask-react project!
It's nice except its still a statement not an expression, C# got it right, Scala got it right, see how pattern matching works in them.
Why not just regex?
regex only matches strings. This can match a lot more python objects
@@dqalombardi hmm you are right
Why dont you use pycharm anymore?
what s the app he s editing in ?
But I Thought Adding Tags In Description Is Banned In RUclips
Hey Tim put python series for socket programming
I will waiting for that bro
It would be great if they make it fast
Please make a video on face recognition!🧡💛❤💚💙💜🤎🥺
check out his OpenCV tutorials the last one covers face recognition
@@simonrobertgreenwoodThankyou so much bro! you're awesome😍. Thankyou so much for the help
@@mathewsjoby6455 no problem :)
Hey try to add some smile to that face!
It feels like injecting some Haskell into python OwO
or it can be written with if statement like a normal programmer :D
This looks a lot useful than it sounds. It'd save me from those pesky if elifs xD
Can *a be replaced by *_ ?
Finally this removes all this big annoying if statements :)
OCML *intensifies*
Python 3.10 is the same as 3.1 though! Where’s python 4?!
since when was 10 = 1. im sure that has some serious complications to maths in general if thats true.
@@Altirix_ decimals man, all zeros after a number that is greater than zero gets cut of, 3.1 == 3.10
@@elishashmalo3731 But these are obviously not formatted as doubles? Version numbers such as 3.9.5 exist
@@testk822 yeh but there has nvr been a 3.10.9 b4. The standard rule (which I believe is called “carry the 1”) still applies. This is a new precedent.
@@elishashmalo3731 its version numbers, not maths rounding or significant figures do not come into play. seriously did you start rounding up to python 4 when you switched to python 3.5? i sure doubt it
recently i realized i've learned alot from Tim but wasn't subscribed. I immediatly did
I came from zero to...i am pretty good right now. Coming from a third world country, the programming taught in school is just so bad(sorry). I made my school projects from what I'd learned from you. Thank you so much. Definitely told my friends about this channel
@@trevormckellen5613 you replied to a bot... -_-
c++ full course please
@Pínned by Tech With Tim ok I will subscribe and smash like button
but what about cpp course
i need cpp
specialy embed system
tim replay
tim please replay by question
Tim I am planning to get a law degree, can I combine it with computer science and cyber security!? Also I don't know any programming language
Insert YandareDev reference here
I'm still a beginner but this appears similar to the try and except.
The try being cases and default(wild card) being the except 🤔
I think try-except is used to catch errors, not for regular pattern-matching.
It looks similar because it does a similar thing, but try-except for a start needs some actual errors to go into the except block - meaning you would need to write the matching in a way, that produces an actual error. The original if-elif-else chains this will replace would need conditions that produce True/False. Meanwhile Match-Case just needs patterns and it will do the comparison for you. No need for conditions, no need for forcing errors.
3rd
Second
We just got rickrolled
Whats the point of this... Couldn't you just make a dictonary of values and get the case from that?
Example:
values = {"x": "This is x"}
my_case = "x"
value = values.get(my_case)
print(value)
it’s probably how you’re supposed to do it. its a lot like using an enum with switch statements in c++
Dictionaries need non-mutable objects as keys and cannot match wildcards either.
So no, it's not the same.
It's also not the same in other languages, as the "break" keyword indicated in the beginning - because switch-case would execute all cases after the first true one. Hence the need to include "break" so it doesn't do that. This can technically be used to combine some cases.
@@jagaya3662 ohhhh... i see
Will it be useful for making video games in 3d?
Rule of thumb. Don't make 3d video games in python
@@rylandavis2976
Oh, really? Civ 4 made in Python btw... and people still play it ( including myself ) they made CyberPink 2077 in C# and took them more than 8 years and then... they screwed everything... waste of time resources...
@@SkyFly19853 civ 4 is not written in python. Certain parts are. Almost all of the underhood stuff is written in a more technical language because of needs to manage performance and resources. Civ 4 allows python scripting tho
@@SkyFly19853 civ 4 was written in c++
@@rylandavis2976
If you check there is plenty of Python with Panda 3d.
Aleluia
Finally it would be easy and less chaotic to make command line programs.