Implementing OAuth 2.0 from SCRATCH
24:56
Python has BIOMETRIC support?!
11:43
21 күн бұрын
What's new in Python 3.13?
5:08
Python is Awesome - Series 2
3:53:48
Python is Awesome - Series 1
3:01:53
7 COOL Python Easter eggs
10:29
2 ай бұрын
5 MORE EASY Python optimisations
15:41
Use THIS instead of pkg_resources
8:01
Пікірлер
@noahchristie5267
@noahchristie5267 3 минут бұрын
We’re you able to solve auto refreshing with the refresh token? I would like this to run in a lambda type environment
@itsmy0406
@itsmy0406 11 сағат бұрын
Error PresentO. An invalid parameler was passed to the returning function how ti fix this?
@arianu2081
@arianu2081 21 сағат бұрын
it didnt CHANGE my life but, nice... It will help a lot
@tahseenjamal
@tahseenjamal 23 сағат бұрын
I asked it to write a factorial function using tail recursion and it couldn't where as Copilot wrote the tail recursion. Basis this at least I can conclude that Copilot is worth its price
@murphygreen8484
@murphygreen8484 Күн бұрын
What a coincidence, I'm eating curry right now
@dhjerth
@dhjerth Күн бұрын
If this is new to anyone I would suggest you read more about process creation on unix. Execv is very useful, indespensible, but for this case you probably want a loop and a try-except instead.
@brailorjs1192
@brailorjs1192 Күн бұрын
this is one of the worst advices i've ever seen on coding youtube
@hurricane478
@hurricane478 2 күн бұрын
Dumb question, what makes this better than using a while loop?
@marcsonic01
@marcsonic01 Күн бұрын
it's not, this is just showcasing a functionality
@avananana
@avananana Күн бұрын
The only reason I can see this being seemingly useful is if you need to reset the entire state of the program in a rather quick and easy way. Could possibly be used to handle unexpected cases or recover from faults without crashing or quitting entirely.
@benn310
@benn310 2 күн бұрын
if you changed the file between running it and re-running it from inside... it would still re-run the old state, right?
@niels6190
@niels6190 Күн бұрын
I don't think it would. Execv replaced the current executing process with the executable found at the specified path, so I think the python interpreter would be invoked again on the executable file
@dhjerth
@dhjerth Күн бұрын
The old state is lost, as is all memory, and by default any files are closed except for in, out, err, but you can mark them to keep them. The pid will remain the same. This is a unix thing, not a python thing, it's actually just the second step of process creation, normally following fork(). I have never seen exec used for "self-restart" though, usually if an application reaches some broken state where it is necessary to completely wipe the slate, that state is not identified by the same application, but instead by some watcher that kills the old process and spawns a new one. This approach to restarting spawns an entire new python intepreter so it's usually not efficient, you're better off preventing broken state in the first place. Though I don't know how python populates sys.executable with the interpreter path, and the docs states you might end up with None or an empty string if it can't figure it out, so that might put some very unexpected things in arg 0 to execv. Be careful if you actually need this for whatever reason.
@iagobeulleryeah
@iagobeulleryeah 2 күн бұрын
I don't like this syntax.
@TheDiamondRoblox
@TheDiamondRoblox 2 күн бұрын
omg I used to use subprocess to run a restart.py file which used subprocess to run my main file again; thank you so much!
@alfredmunoz8132
@alfredmunoz8132 Күн бұрын
Maybe they use it something similar in the back haha
@callyral
@callyral 2 күн бұрын
Currying?
@Axman6
@Axman6 3 күн бұрын
As a functional programmer from Canberra, this bizarro world video title and channel name was very confusing. Glad to see Python providing ways to do programming the way it should be! Can you partially apply more than one argument at a time? Like can you make a partial from a three argument method, then apply it to one argument, then apply that to the second?
@Carberra
@Carberra 3 күн бұрын
I wondered if that would happen some day! Genuinely a complete accident the names are so close lmao. To answer your question, yes, you can pass as many arguments as you like, and you can pass kwargs as well! So where you had def func(x, y, z): ... You could do p = partial(func, 1, 2) p(3)
@Axman6
@Axman6 3 күн бұрын
@@Carberra ha, well glad I could be the first - where’d the name come from? My question is more if you can apply partial to the result of applying partial: x = partial(func,1) y = partial(x,True) z = y(“hello”)
@Carberra
@Carberra 3 күн бұрын
Believe it or not it came from the TVR Cerbera -- used to play a lot of Gran Turismo, Carberra just came from that 😅 Just tried it cos I was curious and looks like it works fine yeah.
@orterves
@orterves 3 күн бұрын
Curried python. Yum. 4:09 I'm not sure why partials are more optimised but my uneducated guess is maybe lambda is a closure and has that overhead, whereas partial creates a function and doesn't have that problem (and partial probably handles the wiring up at a layer closer to the bare metal)
@edgarcabrera602
@edgarcabrera602 3 күн бұрын
Looks like the functools module is implemented in c instead of python, which is interesting. I didn't read the code for partial carefully, but there is something interesting, looks like it doesn't add anything extra to the call stack. I tried something like: def x(a, b): raise Exception("test") y = partial(x, 1) y(2) That shows this traceback: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in x Exception: test If y is instead a lambda or wrapper function then we have; Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in y File "<stdin>", line 2, in x Which kind of makes it look like the function is being rewritten.
@Carberra
@Carberra 3 күн бұрын
That would certain explain why it's faster to execute if there's one less function call. Would be interesting to see the differences using dis.
@TonyDig100
@TonyDig100 3 күн бұрын
I use partial functions in tkinter. Say you have a whole load of buttons that you want to use the same call back function. You can make the call back function take an argument specifying which button was pressed. But the button wants a callback function with zero args so you can use a partial function.
@DT-hb3zu
@DT-hb3zu 3 күн бұрын
Oh that's a great use. I always just use lambda's 😂
@abletmuhtar8979
@abletmuhtar8979 3 күн бұрын
nice!
@nascentnaga
@nascentnaga 3 күн бұрын
this is very interesting. In engineering we have formulas that often have different keyword argument values for units. It could be nice to use a partial to interchange metric and imperial units for example for constants
@advik-b
@advik-b 3 күн бұрын
Underrated channel, also that bri-ish accent is woowwwwww
@Carberra
@Carberra 3 күн бұрын
Fanx m8 😄
@pythonwithjames
@pythonwithjames 4 күн бұрын
Really nice!
@Carberra
@Carberra 3 күн бұрын
Thank you!
@alexdeathway
@alexdeathway 4 күн бұрын
5:04 So it happens to best of us.
@Carberra
@Carberra 3 күн бұрын
Indeed it does!
@KavyanshKhaitan
@KavyanshKhaitan 4 күн бұрын
You dropped a pin 📌 Can i have it?
@KavyanshKhaitan
@KavyanshKhaitan 4 күн бұрын
FIRST
@amos9274
@amos9274 4 күн бұрын
Nope, they don't have infinite precision, instead it calculates a fixed number of digits. It would not, for example, be able to calculate the area of a circle with an integer radius exactly (duhh). All it does is store and calculate decimal digits instead of binary digits.
@mirajalmahmud2534
@mirajalmahmud2534 5 күн бұрын
It changed my life too 😂
@MaxShapira2real
@MaxShapira2real 5 күн бұрын
Love it! Awesome job as always. Could you share the link to the video that shows how type-parameterized decorators were cleaned up and made less messy?
@Carberra
@Carberra 3 күн бұрын
Thanks! Soz forgot to link it kzfaq.info/get/bejne/lbeIn8Wot9PVl30.html
@thomaseb97
@thomaseb97 5 күн бұрын
python generally has really bad syntax for functional concepts and such, it's very opinionated on being object oriented and imperative the type hint for a function is really bad, it can get very bloated with the Callable[[T, U], R] especially when nested and lambdas are not implemented well nor are the syntax intuative using TypeAlias from typing is very helpful to help with the bloating of Callable
@FrozenPear
@FrozenPear 5 күн бұрын
Just because you can doesn't mean you should, this is not a good pattern.
@huyvuquoc6708
@huyvuquoc6708 6 күн бұрын
how did you add space to multiple lines at the same time?
@DanGamingTV
@DanGamingTV 5 күн бұрын
This is a feature in visual studio code, called multiple cursors. Hover over wherever you want to add another cursor then do Alt + Click. Any text you type will be typed out at the locations of both cursors.
@ShortFilmVD
@ShortFilmVD 6 күн бұрын
Nice feature, but I don't like the syntax😢 '=' is the assignment operator, but we're not doing an assignment... Other languages use a named function like 'var_dump' to achieve the same thing. Reading this code without prior knowledge, it's impossible to say what it does. Boo.
@niels6190
@niels6190 3 күн бұрын
A language shouldn't be tailored to people with no prior knowledge. The feature is easy and concise. also, equals is used in a format string so no one expects it to assign anything there
@ShortFilmVD
@ShortFilmVD 3 күн бұрын
@@niels6190 that's true, personal preference though, not the way I'd do it and arguably not the most accessible approach, but it is Python after all, science researchers aren't renowned for their clean code and nor should they be, it's not their perogative.
@divad1196
@divad1196 6 күн бұрын
Are UUID incremental? From what I know, UUID4 have great cryptographical properties (in comparison to uuid3 or 5). This is one of the reasons for using it. I don't know if this ID is filling this need
@sjoerdev
@sjoerdev 6 күн бұрын
what font is this?
@Carberra
@Carberra 6 күн бұрын
Fira Code Nerd Font.
@mangata5833
@mangata5833 6 күн бұрын
man i literally couldn’t figure out why it wasn’t working turns out i forgot the f lol
@Carberra
@Carberra 6 күн бұрын
F in chat, perhaps? 😉
@gvarph7212
@gvarph7212 6 күн бұрын
I love this feature and I've been using it for years, but I never realized you can add spaces around the =
@davidmurphy563
@davidmurphy563 7 күн бұрын
I mean, it's a nice handy little feature, I like it too but... Um.. "Changed your life"...? Ok then!
@Carberra
@Carberra 7 күн бұрын
Considering how much I use it it's not even that hyperbolic lmao. Genuinely one of my fav syntax changes in any version.
@user-my2zq6td8z
@user-my2zq6td8z 7 күн бұрын
it will change mine too insha'Allah thanks
@TheGamer1445_Xbox
@TheGamer1445_Xbox 5 күн бұрын
Yay muslim dev
@Confusedcapybara8772
@Confusedcapybara8772 7 күн бұрын
I’ve never seen the end line r before. Pretty dope
@lindhe
@lindhe 5 күн бұрын
Me neither! Very neat.
@pythonwithjames
@pythonwithjames 8 күн бұрын
This is great, really loved the explanation!
@Carberra
@Carberra 7 күн бұрын
Thanks man! I tried to be very thorough about it cos I get asked about decorators quote a bit, and see quite a lot of confusion about them elsewhere too.
@fletchercutting7301
@fletchercutting7301 8 күн бұрын
Snowflakes is where it's at for anything where you don't care if the user can see them. It takes a little more architecture since you need a worker to generate snowflakes. But they're unique, store a timestamp, and an incrementing int64 making them space efficient and you can use them as your IDs in database and still do sorting, filtering, sharding, etc. The only pain is using them with JavaScript because JavaScript can't handle numbers that large 💀
@GintarasSakalauskas
@GintarasSakalauskas 8 күн бұрын
What is this editor theme called?
@Carberra
@Carberra 8 күн бұрын
Ayu (specifically the Mirage Bordered variant).
@cyrus01337
@cyrus01337 8 күн бұрын
Why not just store a timestamp? I don't see the practicality of this.
@mariocrespodelgado
@mariocrespodelgado 8 күн бұрын
This is very cool! I have created a time decorator called "tempit" which does exactly this but in a more complete way (concurrency, autorecursion checker, etc). You can take a look at the code or install it using pip install tempit. Hope you like it!
@johnlockman9090
@johnlockman9090 8 күн бұрын
Don't store UUIDs as strings, they're in hex, covert to bytes and store them as blobs or using a uuid type. 128 bits now fits in 128 bits.
@AllanSavolainen
@AllanSavolainen 8 күн бұрын
Yeah, converting them when needed is cheap, store binary data as binary when possible.
@forgottenfamily
@forgottenfamily 8 күн бұрын
I had a project where the results of chained calculations were stored with an index of the XOR product of the component UUID4s. Which (1) had a hilarious side effect when one customer hired a different firm to reverse engineer where the calculated values corresponded to and (2) had a hilarious side effect when suddenly we were sourcing our data from a system that wasn't making UUIDs randomly but incrementally...