I love storing funcs in dictionaries to avoid huge switch cases
@pythonwithjamesКүн бұрын
Good call :)
@hashim40494 күн бұрын
got randomly recommended this channel, great video and concept of explaining without code, really helpful for making base of early students! subscribe is deserved
@pythonwithjames4 күн бұрын
thanks so much, I’m glad you liked it :)
@catniptrip88417 күн бұрын
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
@pythonwithjames17 күн бұрын
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!
@bigswede724118 күн бұрын
I have almost 49 years of lowe productivity😂
@BillyT8319 күн бұрын
Thanks for the call out James! Happy Christmas and a 'Pythonic' New Year!
@pythonwithjames17 күн бұрын
Thanks Billy, and same to you!
@murphygreen848419 күн бұрын
So happy you will be continuing these next year!
@Carberra22 күн бұрын
Just a note as I saw it in the notification -- the title says 6 months twice! Thought I'd let you know 😄
@pythonwithjames22 күн бұрын
Haha, how did I miss that one!! Cheers for letting me know.
@rob-89022 күн бұрын
Python is stupid, truthy?
@pythonwithjames22 күн бұрын
The word 'truthy' is quite funny I must admit!
@ItsThatOneJack22 күн бұрын
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.
@Carberra22 күн бұрын
Completely missed this when it came out, whoops! 😅 Interesting to see all the other solutions ~~that didn't cheat like I did~~ lmao.
@pythonwithjames22 күн бұрын
haha :D The December problem is out, if you wanna have a try?
@saiipranay99528 күн бұрын
your explanation is very beginner friendly and detailed, thank you soo much. keep up the work.
@pythonwithjames28 күн бұрын
Thanks so much, glad you found this useful!
@panxel8615Ай бұрын
I love the color scheme of that theme. what's it called?
@pythonwithjamesАй бұрын
Thanks! Its called 'Bearded Theme' available as a VS extension.
@panxel8615Ай бұрын
@@pythonwithjames Thank you!
@mawkuri5496Ай бұрын
will python be faster if you statically declare a variable? like that.. name: str, age: int ?
@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Ай бұрын
@@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Ай бұрын
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Ай бұрын
Ha ha, yeah should have finished the video
@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Ай бұрын
@@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Ай бұрын
@@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Ай бұрын
Thanks. pls keep doing these kind of videos. your videos help me a lot.
@pythonwithjamesАй бұрын
Good to hear they help :)
@tudoriacob8874Ай бұрын
Very instructive. Thank you James
@pythonwithjamesАй бұрын
Glad you enjoyed it!, thanks for watching :)
@murphygreen8484Ай бұрын
Thank you for the call out! It was fun!
@pythonwithjamesАй бұрын
Any time! Thanks for the contribution!
@matthewcane0Ай бұрын
I can see this being really useful paired with 'os.get_console_width()'
@pythonwithjamesАй бұрын
Yes thats a good point!
@rutabega306Ай бұрын
I need this function for my d
@pythonwithjamesАй бұрын
haha :D
@eduardabramovich1216Ай бұрын
Hi, i see that YT has this playlist in reverse order, do you have any way to fix it please?
@pythonwithjamesАй бұрын
Hi Eduard, I'll take a look at this!
@bawbaw1228Ай бұрын
little problem with aiofiles
@pythonwithjamesАй бұрын
Whats the issue you're seeing?
@pythonwithjamesАй бұрын
Whats the issue you're seeing?
@bawbaw1228Ай бұрын
@@pythonwithjames in myapp terminal: ModuleNotFoundError: No module named 'aiofiles'
@bawbaw1228Ай бұрын
i resolve the problem, it's was an environment issue. thank you a lot for your work
@pythonwithjamesАй бұрын
@@bawbaw1228 Glad you managed to get it sorted, thanks a lot :)
@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Ай бұрын
Thanks for the advice! I only generally tend to use this for local development :)
@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Ай бұрын
Thank you :)
@danielclare2079Ай бұрын
Great video. Very helpful
@pythonwithjamesАй бұрын
Glad you think so!
@7n7oАй бұрын
how to make diffs in python: 1. import somebody elses diff code 2. profit
@pythonwithjamesАй бұрын
That’s the way! why reinvent the wheel :)
@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Ай бұрын
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Ай бұрын
@@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Ай бұрын
haha, I'd hope not! :D
@marcusjtАй бұрын
It seems confusing (and surely bad practice) to replace the "diffs" Differ object with an array (the output)
@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Ай бұрын
@@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Ай бұрын
Noted :)
@onejdcАй бұрын
Great video. Had no idea about pickle. that's a game changer for larger projects.
@pythonwithjamesАй бұрын
It's great isn't it! I've used it a couple of times in big projects and its really quite useful.
@murphygreen8484Ай бұрын
Did my solution not make it?
@pythonwithjamesАй бұрын
Hello! Did it get sent via email?? I can re-upload with it at the start, awfully sorry!
@murphygreen8484Ай бұрын
@pythonwithjames no worries! I think I had a hard time finding your email. I can submit for next month's 👍🏼
@pythonwithjamesАй бұрын
Apologies again! I'll be releasing Novembers fairly shortly. Take care, James-
@murphygreen8484Ай бұрын
@@pythonwithjames which email should I send the submission to?
@pythonwithjamesАй бұрын
its [email protected] Feel free to ping me a Hello and I can reply, just to check its correct.
@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Ай бұрын
Ah yeah, that’s a super smart idea!! cheers :)
@rutabega306Ай бұрын
Sorting is O(nlogn). Optimal solution is O(N) So sorting is a good solution, but not "fastest"
@j7m7fАй бұрын
@rutabega306 right
@pythonwithjamesАй бұрын
@@rutabega306 thanks for the input :)
@shubhamshah93582 ай бұрын
started learning fastapi without even knowing python (coming from js) and i understood everything you took me through. Thankyousokmuch!
@shubhamshah93582 ай бұрын
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
@pythonwithjames2 ай бұрын
That's great, im glad this has been helpful!
@pythonwithjames2 ай бұрын
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-c2v2 ай бұрын
What theme are you using for your ide man?
@pythonwithjames2 ай бұрын
yo! it’s called ‘bearded theme’
@Shishankagrawal-g2f2 ай бұрын
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?
@pythonwithjames2 ай бұрын
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
@lucascosta51192 ай бұрын
good video!
@pythonwithjames2 ай бұрын
Glad you enjoyed it
@hungcarl2 ай бұрын
Kaizen Just means 改善 which means improvement. Don’t make it like a secret recipe.
@pythonwithjames2 ай бұрын
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_LukeZ2 ай бұрын
I learned tgat the condition comes after the loop
@pythonwithjames2 ай бұрын
the condition can also be applied at the end, and then the ternary will consider all the items that matched the condition
@cryptolith5062 ай бұрын
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_LukeZ2 ай бұрын
@@cryptolith506 ah okay, interesting 👌🏻
@pythonwithjames2 ай бұрын
Thanks for this!
@tigerchills20792 ай бұрын
adding more and more operators in a single line.. this gives me the SQL vibes. does python have optional brackets?
@DatGamer8952 ай бұрын
Yeah this is really difficult for readability
@pythonwithjames2 ай бұрын
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.
@pythonwithjames2 ай бұрын
Another option is to make a function to handle the if/else logic and then call the function inside the comprehension.
@gJonii2 ай бұрын
You can split list comprehensions on multiple lines. It's how I usually handle those if it gets at all complex.