You Should Be Using This For Work/Research in Python | OOP Tutorial

  Рет қаралды 33,096

Mr. P Solver

Mr. P Solver

Күн бұрын

In this video I give a brief overview of Object Oriented Programming in python and how it can be used to help organize complicated problems and make your work speed much more efficient.
Code:
github.com/lukepolson/youtube...
Discord:
/ discord
0:00 Video Introduction
1:08 Beginner: How To Use Classes
9:00 Beginner: Inheritance of Classes
16:26 Intermediate Problem
27:42 Advanced Problem

Пікірлер: 68
@viniciusraphaeldasilva3593
@viniciusraphaeldasilva3593 2 жыл бұрын
Dude, I must say: you're responsible for a significant part of my engineering degree
@alboz1327
@alboz1327 2 жыл бұрын
Same, dude's A geniuS
@Hacker-at-Large
@Hacker-at-Large 2 жыл бұрын
Nice introduction. Note: “self” is not a keyword, it’s just a convention (strongly encouraged), and super(), without parameters, is entirely sufficient to resolve the parent class.
@MrPSolver
@MrPSolver 2 жыл бұрын
Interesting, good to know!
@PabloElPianista
@PabloElPianista 2 жыл бұрын
This channel was great for me, I am finishing the degree in physics in Spain and I learned a lot about the Python necessary to overcome and analyze the data in laboratories such as Nuclear. Keep uploading cool simulations! :)
@sokhengdin8012
@sokhengdin8012 Жыл бұрын
This is great! Such a motivation video for making complex functions for my robotics project! Keep up the good work
@eleTechnologies
@eleTechnologies 2 жыл бұрын
These videos are really helpful. I like how you take time to discuss the details.
@AJ-et3vf
@AJ-et3vf Жыл бұрын
Wow! Awesome video! Thank you! Very timely and relevant especially for me. I've started learning and implementing Python classes in my code because I'm now dabbling with coding spline functions in Python e.g. Linear, Quadratic, or Cubic Splines and their several subtypes e.g. periodic, clamped, natural, not-a-knot, etc. Classes become necessary when coding these because you need to have a way to be able to hold on to the x and y inputs you give and then pass and manipulate them to form the spline function you want to use. Doing it by functional programming becomes tedious because you would then have to define a lot of functions in your name space, "polluting" the name space so to speak. Again, thank you very much for this.
@heltown2318
@heltown2318 2 жыл бұрын
These videos are incredibly helpful. Thank you so much for your effort.
@lakshyavaibhavdatta9098
@lakshyavaibhavdatta9098 Жыл бұрын
I had this course for like a semester in my first year of undergrad, and then I forgot about it. And I've tried to learn this again multiple times over the past 8 years, and I just got more and more confused. And it all makes sense to me again. Thanks, dude. This is life changing.
@adityaalmighty1
@adityaalmighty1 2 жыл бұрын
Really well explained! The scientific example certainly helps a lot. Cheers!
@zaid_uiuc
@zaid_uiuc Жыл бұрын
Your python tutorials are really helpful. Thanks a ton!!
@user-vx3jm1vi6p
@user-vx3jm1vi6p Жыл бұрын
Thank you so much
@slvfelix
@slvfelix Жыл бұрын
Excellent explanation. Thanks a lot for giving us this!
@joeheafner2495
@joeheafner2495 2 жыл бұрын
Great video as always. I think you used the electron’s mass rather than the proton’s mass. Only affects some of the numbers, but just to let you know.
@MrPSolver
@MrPSolver 2 жыл бұрын
Hahahaha of course I did 🤦someone needs to take away my MSc in particle physics
@PerteTotale
@PerteTotale Жыл бұрын
I'd say nuclear engineering is not his perfect🎆 kind of job thing...
@hemantikasengar4902
@hemantikasengar4902 Жыл бұрын
Thank you so much for such great videos. It would be awesome if you could make a on Monte Carlo using OOP approach.
@reciofcosc
@reciofcosc 2 жыл бұрын
Thank you so much for uploading such wonderful videos….
@Eighty_80_WAW
@Eighty_80_WAW 2 жыл бұрын
you are special. Different from several KZbinrs out there.
@kychemclass5850
@kychemclass5850 Жыл бұрын
I really like this video. Thank you.!!!
@ilyashulika3538
@ilyashulika3538 2 жыл бұрын
Great video )) Very very useful))
@gammaian
@gammaian Жыл бұрын
Man, you are a boss! Thank you
@hakansert13
@hakansert13 2 жыл бұрын
great video!
@rufusbabatundelot1869
@rufusbabatundelot1869 2 жыл бұрын
Thanks you for your efforts. Please show tutorial on how to use python for denoise., to remove noise from audio.
@frankkoslowski6917
@frankkoslowski6917 Жыл бұрын
I do recommend testing the code in PyCharm. "Shadows name from outer scope" are only minor errors. For example: Keeping the name for the functions `move()` in class Particle and class Proton the same results in a warning: "Signature of method 'Proton.move()' does not match signature of the base method in class 'Particle'". Traceback errors follow on program execution. Ambiguity with inheritance can arise when the parent class and the child class have both a function with the same name, but are doing somewhat different things.
@flatproduction7878
@flatproduction7878 2 жыл бұрын
oh god another video i can watch more than 5 times to consume till the last grain
@Louis-ml1zr
@Louis-ml1zr 2 жыл бұрын
Cool vidéo thanks !
@Manitavakoli
@Manitavakoli Жыл бұрын
My deepest regret is that I didn't learn Python when I was an engineering student. Thanks for sharing your expertise mate.
@robertpretorius7627
@robertpretorius7627 2 жыл бұрын
DUDE! This is the most awesome stuff I've seen on youtube yet! Could I request a topic as a lowly medical / biology dude myself? I love the power of mathematics and I know how to program but for the life of me I cannot suffer through integrals and differentials on paper. But then I saw your videos! You can just outsource the boring stuff to python using Sympy??? Now my question, could you teach people like myself how to take a real-life problem and formulate it in a mathematically sound way using differentials and whatnot? Concretely I've tried today to figure out a solution for a problem where you have water flowing into a tank at a certain speed but it has a hole in the bottom where water flows out as well. The only progress I've made however is fill this tank with my own tears of frustration. Or another example let's say I want to try something crazy and apply the diffusion equation to images, how would I go from the conceptual idea to having constructed the basic math needed to kick off the sympy solver? Thanks anyways for the awesome content! Greetings from Belgium!
@4001Jester
@4001Jester Жыл бұрын
Just to say something about your diffusion equation comment-sympy is good at solving *ordinary* diffeqs, but the diffusion equation is a *partial* diffeq. as far as I know, you would have to solve it by hand, use an analytic solver more sophisticated than sympy, or come up with a scheme (like finite difference method) to solve it numerically.
@PerteTotale
@PerteTotale Жыл бұрын
"problem where you have water flowing into a tank at a certain speed but it has a hole in the bottom where water flows out as well"? see Darcy equation for outflow, but you have inflow too, so make sure is there conservatoin of mass the reality is that you have to include soil props and aquifer props as well, but most ignore one of these amazing thing is that along the way you'll see that hydraulic heads move with the moon and sun tides, if your reservoir is big enuff
@Crilic3
@Crilic3 Жыл бұрын
Hey do you have OOP stuff using Numpy and Matplotlib, including object movement? Hundreds of us would find that useful for uni python class. The unit is super hard and it's refreshingly easy to understand and engage in your content. If not, PRETTY please?!
@Tensor-An
@Tensor-An 2 жыл бұрын
Yo, my guy, you are the best 😎
@rio_agustian_
@rio_agustian_ 2 жыл бұрын
Cool!
@librealgerien
@librealgerien 2 жыл бұрын
The mistake I noticed in your Proton class is that you used the mass of the electron instead. The mass should be \(1.67\times10^{-27}\). So the displacements should be about a 1000 times less.
@Abvht1656
@Abvht1656 4 ай бұрын
Useful
@unverozkol
@unverozkol Жыл бұрын
You are a gem
@bryanstark324
@bryanstark324 Жыл бұрын
As a noob to python, I came in with some OOP experience, and I'm doing Angela Yu's python course on Udemy. She does more procedural programming, but I wanted to make all my code OOP, so for games in Tkinter or Turtle, I make a class for each object so I can change properties. So I just send attributes to a label function in the class, and it will add a label with all the attributes I want (location, text, font, etc.). It's taking me longer to finish the course, but I think I will finish with stronger skills than most people who complete the course. What do you think?
@mrsmokpiano
@mrsmokpiano Жыл бұрын
Hi, dude! I'm also doing the same course and am a little stuck on the snake project and classes.
@mirkodegliesposti4597
@mirkodegliesposti4597 8 ай бұрын
your movies are great and a very recent plesent discovery for me...thanks...but here at 30. 40. the "self.x, self.vx, self.y, self.vy = self.solution.y"...really do not understand the final ".y".... i missing something but i do not know what...thanks for any help
@mirkodegliesposti4597
@mirkodegliesposti4597 8 ай бұрын
I got it !!! thanks
@slimanebenlala2622
@slimanebenlala2622 11 ай бұрын
Why the use of self.something ? what is it exactly ?
@jhawar-ji
@jhawar-ji 2 жыл бұрын
I work with OOP in Python but still watching this 👀
@VegasTechno
@VegasTechno 2 жыл бұрын
Hi! Recommended Reading/Watching: Stop Writing Classes at kzbin.info/www/bejne/pWrTdq2dfdSlfpI Dataclasses: docs.python.org/3/library/dataclasses.html Classes are great for a lot of things. Most programming in Python doesn't need many classes. Regular python files are already "module" objects that gives you the thing.do_something() pattern that feels nice. You can also pass functions as arguments to other functions if you want flexible behavior. If you're working with complex data types, then classes are great. If you're creating new classes that are not datatypes, but rather express a lot of the behavior of your application or library, you might be getting on a rollercoaster that you can't get off of.
@0ferchen
@0ferchen 2 жыл бұрын
I would recommend not using a single or double character length variables because it becomes a hassle to follow all these letters.
@gdmitrich
@gdmitrich Жыл бұрын
why didnt you add self.q to a super class?🤔 15:37
@flatproduction7878
@flatproduction7878 2 жыл бұрын
hey, you have written github in the description instead of discord channel I guess
@Makabaril
@Makabaril 2 жыл бұрын
No love for dataclasses?
@davidjohnston4240
@davidjohnston4240 2 жыл бұрын
Hmm. Functional programming constraints led to complicated code. Whodathunk? If you need to calculate a Fibonacci sequence, functional programming is fine but it tends to fall over when you get into real systems that need to maintain and transform state.
@iridium1118
@iridium1118 2 жыл бұрын
There's plenty written about how promiscuous state sharing leads to essentially global state. The promise of encapsulation is a lie.
@gokhanY
@gokhanY Жыл бұрын
Dude, you mixed up the mass of the proton with the mass of the electron 11:28 Not that it matters that much for this particular case though.
@GrumpDog
@GrumpDog Жыл бұрын
I love Python, but the use of "self." has always driven me a little nuts. I know there's good reasons for it, it's just the vast majority of everything you do in a class, is altering that class's attributes, so why do we always have to specify that which should be the default? Wouldn't it make more sense if "self" was inferred while within a class, and only when accessing an outside object, variable or global, would we have to specify with some kinda tag, like 'global.' I've looked up why in the past, just still bugs me I end up with 'self.' all over the place. heh
@iridium1118
@iridium1118 2 жыл бұрын
Functional programming gang rise up
@theultimatereductionist7592
@theultimatereductionist7592 2 жыл бұрын
I avoid classes in Python like the plague had covid19.
@frankkoslowski6917
@frankkoslowski6917 Жыл бұрын
Puzzled over the trickery below for a while because `p1.solve_motion()` was constantly throwing errors. It's working now. Gonna test the algorithm a tad more thoroughly in PyCharm since it allows excellent tracing of variables and functions all the way into the Python core modules. # Solving a system of differential equations: self.solution = solve_ivp(dSdt, [min(self.t), max(self.t)], [self.x0, self.vx0, self.y0, self.vy0], t_eval=self.t, args=self.args) self.x, self.vx, self.y, self.vy = self.solution.y
@marcinpohl3264
@marcinpohl3264 Жыл бұрын
Naming a callable F in code dealing with kinematics is a bad idea. I saw it and just assumed it's a Force, until you explained it. Short names are bad, short names without comments, in situation where there's another entity that happens to have a similar short name are just terrible. Please call it `func` or something. Awesome otherwise!
@user-gh4lv2ub2j
@user-gh4lv2ub2j 6 ай бұрын
**Writes procedural code, calls it functional** WhY iS mY SpHaGeT nOt WoRkIn???
@alexgillespie1098
@alexgillespie1098 Жыл бұрын
eew no, functional ALWAYS better than OOP. It's a dumb paradigm. Adds too much abstraction for no reason
@simonpeggboard4004
@simonpeggboard4004 2 жыл бұрын
OOP is not a good programming paradigm. If the functional code was larger than OOP then you have not refactored adequately.
@MrPSolver
@MrPSolver 2 жыл бұрын
That's a pretty bold statement. According to who?
@simonpeggboard4004
@simonpeggboard4004 2 жыл бұрын
@@MrPSolver Edsger W. Dijkstra (Pioneer of computer science) 'Object oriented programs are offered as alternatives to correct ones…'' Dr. Simon Peyton Jones. (Haskell) Joe Armstrong (The creator of Erlang) 'The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.' Linus Torvalds (the creator of Linux) OOP is a horrible limiting your project to C means that people don’t screw things up with any idiotic “object model” CRAP. Brian Will - "Object-Oriented Programming is just Bad". OOP _fails_ at the only task it was intended to address, to _manage the complexity_ of procedural codebases. In other words, it was supposed to _improve code organization._ Good on paper , clean hierarchies of animals, dogs, humans, etc. Then falls flat when the complexity of the application starts increases. Instead of reducing complexity, it encourages promiscuous _sharing of_ mutable state and introduces additional complexity with its numerous design patterns. OOP makes common development practices, like refactoring and testing, needlessly complex. Even those who follow OOP generally implement it poorly. Jack Diederich - 'OOP Classes are overused' As for the refactoring statement. Functional Programming and Data-Oriented Design is demonstrablby more compact than OOP when implemented correctly, ergo repetition or bloat code not refactored.
@kejtos5
@kejtos5 Жыл бұрын
@@MrPSolver kzbin.info/www/bejne/h36Umoiba66inK8 this one is somewhat 'famous' on ytb. But this notion seems to be pretty prevelant as of late.
@harp-692
@harp-692 2 жыл бұрын
why are you smart and good looking? sounds like a scam
@netyimeni169
@netyimeni169 Жыл бұрын
Sorry but I physically cannot look at your videos because of light theme. No offense.
@epgui
@epgui Жыл бұрын
What you showed us on screen at 0:18 is NOT what functional programming looks like. If you think you're doing FP in python, you probably aren't (unless you're bending over backwards). Please stop using the words "functional programming" if you don't know what it means. Functional programming is more abstract, more expressive and cleaner than OOP, and it's apparently not at all what you think it is. The term you're probably looking for is "imperative programming", and yeah, that sucks. But it has NOTHING to do with FP. In fact, FP is the polar opposite of imperative programming, and OOP is much more closer to imperative programming than to FP.
@RameezRaja-qc9fi
@RameezRaja-qc9fi 5 ай бұрын
please make video series on numerical heat transfer and fluid mechanics . Always best regards,
@frankkoslowski6917
@frankkoslowski6917 Жыл бұрын
You do this sort of thing in PyCharm, and it will give you an Unresolved reference `m` error. def solve_motion(self): def dSdt(t, S, *args): # for vector `S=x, vx, y, vy` return the derivative. x, vx, y, vy = S return [vx, self.F(t, x, y, vx, vy, m, *args)[0] / self.m, vy, self.F(t, x, y, vx, vy, m, *args)[1] / self.m] It also thinks that defining the instant atribute `solution` outside __init__ stinks. The same holds true for `x`, `y`, `vx`, `vy`. Not to mention the triviality of shadowing variable names from the outer scope.
SciPy curve_fit: What is "pcov"?
31:24
Mr. P Solver
Рет қаралды 12 М.
The Most Important Object In Python: A Full Tutorial
32:55
Mr. P Solver
Рет қаралды 40 М.
Cute Barbie gadgets 🩷💛
01:00
TheSoul Music Family
Рет қаралды 67 МЛН
小路飞姐姐居然让路飞小路飞都消失了#海贼王  #路飞
00:47
路飞与唐舞桐
Рет қаралды 93 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 47 МЛН
What is "self" in Python?
2:23
Python for Everyone
Рет қаралды 97 М.
How To Use: "@dataclass" In Python (Tutorial 2023)
15:01
Indently
Рет қаралды 24 М.
Python Object Oriented Programming in 10 minutes 🐍
10:04
Bro Code
Рет қаралды 335 М.
How I Organize Data In Python with Dataclasses
10:04
John Watson Rooney
Рет қаралды 26 М.
How To Interpolate Data In Python
15:21
Mr. P Solver
Рет қаралды 45 М.
Decorators - Advanced Python Tutorial #2
17:51
NeuralNine
Рет қаралды 85 М.
Expert Python Tutorial #4 - Decorators
16:17
Tech With Tim
Рет қаралды 111 М.
Why I prefer attrs over dataclasses
6:21
mCoding
Рет қаралды 60 М.
5 Tips For Object-Oriented Programming Done Well - In Python
16:08
Learn Classes in Python in 4 Minutes
3:35
Hallden
Рет қаралды 359 М.
Выложил СВОЙ АЙФОН НА АВИТО #shorts
0:42
Дмитрий Левандовский
Рет қаралды 667 М.
Что еще за Smartisan?
0:49
Не шарю!
Рет қаралды 306 М.