Can you actually Master Python?
12:14
Пікірлер
@murphygreen8484
@murphygreen8484 Күн бұрын
I love storing funcs in dictionaries to avoid huge switch cases
@pythonwithjames
@pythonwithjames Күн бұрын
Good call :)
@hashim4049
@hashim4049 4 күн бұрын
got randomly recommended this channel, great video and concept of explaining without code, really helpful for making base of early students! subscribe is deserved
@pythonwithjames
@pythonwithjames 4 күн бұрын
thanks so much, I’m glad you liked it :)
@catniptrip884
@catniptrip884 17 күн бұрын
strikes me as "consistency is key". for example every morning before work, I start at 11 AM, I take 30-45min on learning, on the weekend in continue this as my free time allows me to. Summed up over the course of a year you rack up some time on education. You can have a cup of coffee or two while working on something that is beneficial to you. I believe it comes naturally for people that are busy but are willing to commit time on a regular basis to whatever they pursue. So I can totally imagine these guidelines to have positive effects on your work and energylevels. cheers
@pythonwithjames
@pythonwithjames 17 күн бұрын
Hi there, i’m glad to hear this works for you too! 30-45 minutes each day over a year would rack up a hefty amount of learning i’d imagine! Cheers, and all the best!
@bigswede7241
@bigswede7241 18 күн бұрын
I have almost 49 years of lowe productivity😂
@BillyT83
@BillyT83 19 күн бұрын
Thanks for the call out James! Happy Christmas and a 'Pythonic' New Year!
@pythonwithjames
@pythonwithjames 17 күн бұрын
Thanks Billy, and same to you!
@murphygreen8484
@murphygreen8484 19 күн бұрын
So happy you will be continuing these next year!
@Carberra
@Carberra 22 күн бұрын
Just a note as I saw it in the notification -- the title says 6 months twice! Thought I'd let you know 😄
@pythonwithjames
@pythonwithjames 22 күн бұрын
Haha, how did I miss that one!! Cheers for letting me know.
@rob-890
@rob-890 22 күн бұрын
Python is stupid, truthy?
@pythonwithjames
@pythonwithjames 22 күн бұрын
The word 'truthy' is quite funny I must admit!
@ItsThatOneJack
@ItsThatOneJack 22 күн бұрын
Truthy is a term in C, C++, Rust, Python, Julia, Javascript, Java, PHP, Ruby and many other modern programming languages, it is a system that (as far as I can find) originated with C and was just taken by each language after it and changed slightly, mainly changing that values that are considered falsy.
@Carberra
@Carberra 22 күн бұрын
Completely missed this when it came out, whoops! 😅 Interesting to see all the other solutions ~~that didn't cheat like I did~~ lmao.
@pythonwithjames
@pythonwithjames 22 күн бұрын
haha :D The December problem is out, if you wanna have a try?
@saiipranay995
@saiipranay995 28 күн бұрын
your explanation is very beginner friendly and detailed, thank you soo much. keep up the work.
@pythonwithjames
@pythonwithjames 28 күн бұрын
Thanks so much, glad you found this useful!
@panxel8615
@panxel8615 Ай бұрын
I love the color scheme of that theme. what's it called?
@pythonwithjames
@pythonwithjames Ай бұрын
Thanks! Its called 'Bearded Theme' available as a VS extension.
@panxel8615
@panxel8615 Ай бұрын
@@pythonwithjames Thank you!
@mawkuri5496
@mawkuri5496 Ай бұрын
will python be faster if you statically declare a variable? like that.. name: str, age: int ?
@pythonwithjames
@pythonwithjames Ай бұрын
We're technically not declaring them here, but by providing 'str' as a type hint to the dataclass, we give some information to whoever is using the class that we're expecting name and age to be strings and integers respectively.
@panxel8615
@panxel8615 Ай бұрын
@@pythonwithjames You didn't exactly answer their original question. Python Type hinting is ignored when the python code is ran. you can say that type hinting is similar to comments when used in python. they only benefit the people reading the code.
@murphygreen8484
@murphygreen8484 Ай бұрын
Just got through the first half but haven't watched the dictionary solution yet - but what is wrong with iterating over every number once, subtracting that number from the target and seeing if that number is in the list?
@murphygreen8484
@murphygreen8484 Ай бұрын
Ha ha, yeah should have finished the video
@pythonwithjames
@pythonwithjames Ай бұрын
Hey! That actually is a valid solution, but seeing if the number is In the list would end up with the exponential time complexity :)
@murphygreen8484
@murphygreen8484 Ай бұрын
@@pythonwithjames yeah, realized that after the brilliant solution. I use pandas a lot for work (so probably see solutions with it even when better exist ) but would turning the list into a Series also work?
@pythonwithjames
@pythonwithjames Ай бұрын
@@murphygreen8484 Pandas could be a nice way forward for this! The only thing you'd need to do is look up the time complexity for searching a Dataframe/Series :)
@sidds09
@sidds09 Ай бұрын
Thanks. pls keep doing these kind of videos. your videos help me a lot.
@pythonwithjames
@pythonwithjames Ай бұрын
Good to hear they help :)
@tudoriacob8874
@tudoriacob8874 Ай бұрын
Very instructive. Thank you James
@pythonwithjames
@pythonwithjames Ай бұрын
Glad you enjoyed it!, thanks for watching :)
@murphygreen8484
@murphygreen8484 Ай бұрын
Thank you for the call out! It was fun!
@pythonwithjames
@pythonwithjames Ай бұрын
Any time! Thanks for the contribution!
@matthewcane0
@matthewcane0 Ай бұрын
I can see this being really useful paired with 'os.get_console_width()'
@pythonwithjames
@pythonwithjames Ай бұрын
Yes thats a good point!
@rutabega306
@rutabega306 Ай бұрын
I need this function for my d
@pythonwithjames
@pythonwithjames Ай бұрын
haha :D
@eduardabramovich1216
@eduardabramovich1216 Ай бұрын
Hi, i see that YT has this playlist in reverse order, do you have any way to fix it please?
@pythonwithjames
@pythonwithjames Ай бұрын
Hi Eduard, I'll take a look at this!
@bawbaw1228
@bawbaw1228 Ай бұрын
little problem with aiofiles
@pythonwithjames
@pythonwithjames Ай бұрын
Whats the issue you're seeing?
@pythonwithjames
@pythonwithjames Ай бұрын
Whats the issue you're seeing?
@bawbaw1228
@bawbaw1228 Ай бұрын
@@pythonwithjames in myapp terminal: ModuleNotFoundError: No module named 'aiofiles'
@bawbaw1228
@bawbaw1228 Ай бұрын
i resolve the problem, it's was an environment issue. thank you a lot for your work
@pythonwithjames
@pythonwithjames Ай бұрын
@@bawbaw1228 Glad you managed to get it sorted, thanks a lot :)
@rutabega306
@rutabega306 Ай бұрын
Just be aware that pickle can be exploited if third-parties have access to the serialized objects (like if you send it over the wire). If you only need to store data, better to serialize another way like json.
@pythonwithjames
@pythonwithjames Ай бұрын
Thanks for the advice! I only generally tend to use this for local development :)
@ilonachan
@ilonachan Ай бұрын
just to note for those interested, diff is a tool that has existed for a long time separate from git. Not sure abt the history, but it seems to be the de facto standard format now.
@pythonwithjames
@pythonwithjames Ай бұрын
Thank you :)
@danielclare2079
@danielclare2079 Ай бұрын
Great video. Very helpful
@pythonwithjames
@pythonwithjames Ай бұрын
Glad you think so!
@7n7o
@7n7o Ай бұрын
how to make diffs in python: 1. import somebody elses diff code 2. profit
@pythonwithjames
@pythonwithjames Ай бұрын
That’s the way! why reinvent the wheel :)
@JTCF
@JTCF Ай бұрын
​@@pythonwithjames well then it's just usage of a library, so it's not "make diffs in python" but "make diffs in python with this library". That's an important difference.
@Reelix
@Reelix Ай бұрын
Then you find someones "Diff as a Service" online product costing $50 a month with 400 registered users, and you look at it and wonder...
@pythonwithjames
@pythonwithjames Ай бұрын
@@JTCF I would generally count functions and classes in the standard library to be 'in Python'. If this was a pip-installable 3rd party library then I'd agree!
@pythonwithjames
@pythonwithjames Ай бұрын
haha, I'd hope not! :D
@marcusjt
@marcusjt Ай бұрын
It seems confusing (and surely bad practice) to replace the "diffs" Differ object with an array (the output)
@pythonwithjames
@pythonwithjames Ай бұрын
Well it depends entirely on the use case. I've written the code in this way so it can be shown in as simple manner as possible, given the screen size dimensions that YT shorts allows me :)
@hashinova
@hashinova Ай бұрын
@@pythonwithjamesit’s the same number of lines to use a different variable name for the Differ, with the advantage that you can use it more than once.
@pythonwithjames
@pythonwithjames Ай бұрын
Noted :)
@onejdc
@onejdc Ай бұрын
Great video. Had no idea about pickle. that's a game changer for larger projects.
@pythonwithjames
@pythonwithjames Ай бұрын
It's great isn't it! I've used it a couple of times in big projects and its really quite useful.
@murphygreen8484
@murphygreen8484 Ай бұрын
Did my solution not make it?
@pythonwithjames
@pythonwithjames Ай бұрын
Hello! Did it get sent via email?? I can re-upload with it at the start, awfully sorry!
@murphygreen8484
@murphygreen8484 Ай бұрын
@pythonwithjames no worries! I think I had a hard time finding your email. I can submit for next month's 👍🏼
@pythonwithjames
@pythonwithjames Ай бұрын
Apologies again! I'll be releasing Novembers fairly shortly. Take care, James-
@murphygreen8484
@murphygreen8484 Ай бұрын
@@pythonwithjames which email should I send the submission to?
@pythonwithjames
@pythonwithjames Ай бұрын
its [email protected] Feel free to ping me a Hello and I can reply, just to check its correct.
@j7m7f
@j7m7f Ай бұрын
If you can assume that there is majority in the input, the fastest solution is just to sort the list and take element in the middle.
@pythonwithjames
@pythonwithjames Ай бұрын
Ah yeah, that’s a super smart idea!! cheers :)
@rutabega306
@rutabega306 Ай бұрын
Sorting is O(nlogn). Optimal solution is O(N) So sorting is a good solution, but not "fastest"
@j7m7f
@j7m7f Ай бұрын
@rutabega306 right
@pythonwithjames
@pythonwithjames Ай бұрын
@@rutabega306 thanks for the input :)
@shubhamshah9358
@shubhamshah9358 2 ай бұрын
started learning fastapi without even knowing python (coming from js) and i understood everything you took me through. Thankyousokmuch!
@shubhamshah9358
@shubhamshah9358 2 ай бұрын
altho why are you using venv to create things in myapp, couldnt you just start myapp using poetry new myapp and then poetry add fastapi uvicorn etc. and then poetry run? do i really need to start a virtual environment if im using poetry
@pythonwithjames
@pythonwithjames 2 ай бұрын
That's great, im glad this has been helpful!
@pythonwithjames
@pythonwithjames 2 ай бұрын
So I like to use a virtual environment for each of my projects, and I let Poetry manage the dependencies for that project. It's not 100% essential, but I feel that it keeps all the dependencies neat and tidy.
@Ashish-dev-c2v
@Ashish-dev-c2v 2 ай бұрын
What theme are you using for your ide man?
@pythonwithjames
@pythonwithjames 2 ай бұрын
yo! it’s called ‘bearded theme’
@Shishankagrawal-g2f
@Shishankagrawal-g2f 2 ай бұрын
great video! but i have some questions- can I add this middleware for only some of my apis, not all? or if there is another way of intercepting my api functions?
@pythonwithjames
@pythonwithjames 2 ай бұрын
Hello, thanks and im glad you like it! if you want to do it selectively, I would recommend using a decorator and a custom function, because the normal middleware will intercept it all. There's a nice article here on such a use case: www.pythonbynight.com/blog/building-decorator-for-fastapi Hope this helps
@lucascosta5119
@lucascosta5119 2 ай бұрын
good video!
@pythonwithjames
@pythonwithjames 2 ай бұрын
Glad you enjoyed it
@hungcarl
@hungcarl 2 ай бұрын
Kaizen Just means 改善 which means improvement. Don’t make it like a secret recipe.
@pythonwithjames
@pythonwithjames 2 ай бұрын
I think in my view, I see it a bit like a secret recipe. I often hear stories about people doing these massive grinds and going all-out in an unsustainable way, trying to get better at code. Whereas, if we use the Kaizen method, we get sustainable and useful improvements that actually last :)
@The_LukeZ
@The_LukeZ 2 ай бұрын
I learned tgat the condition comes after the loop
@pythonwithjames
@pythonwithjames 2 ай бұрын
the condition can also be applied at the end, and then the ternary will consider all the items that matched the condition
@cryptolith506
@cryptolith506 2 ай бұрын
The condition after the loop is called the predicate and it filters the elements of the iteration. [x * 2 for x in range(5) if x > 2] will give you [6, 8] [x * 2 if x > 2 else None for x in range(5)] will give you [None, None, None, 6, 8]
@The_LukeZ
@The_LukeZ 2 ай бұрын
@@cryptolith506 ah okay, interesting 👌🏻
@pythonwithjames
@pythonwithjames 2 ай бұрын
Thanks for this!
@tigerchills2079
@tigerchills2079 2 ай бұрын
adding more and more operators in a single line.. this gives me the SQL vibes. does python have optional brackets?
@DatGamer895
@DatGamer895 2 ай бұрын
Yeah this is really difficult for readability
@pythonwithjames
@pythonwithjames 2 ай бұрын
I see what you mean about the SQL vibes haha! Admittedly I found this syntax a bit tricky at first, but I think If this is as complex as it gets in terms of tenaries/comprehensions then it's ok after a while.
@pythonwithjames
@pythonwithjames 2 ай бұрын
Another option is to make a function to handle the if/else logic and then call the function inside the comprehension.
@gJonii
@gJonii 2 ай бұрын
You can split list comprehensions on multiple lines. It's how I usually handle those if it gets at all complex.
@pythonwithjames
@pythonwithjames 2 ай бұрын
@@gJonii That's true, another good option :)