Тёмный
anthonywritescode
anthonywritescode
anthonywritescode
Подписаться
Various videos about programming and related topics. Most videos will feature open source software and programming best practices. For now, most videos will deal with python.

All slides and associated code are on github: github.com/anthonywritescode
using the 3ds touch screen without touch!?
10:43
4 месяца назад
my thoughts on ruff
3:41
5 месяцев назад
automating the nintendo 3ds (hardware mod)
19:21
10 месяцев назад
Комментарии
@oliversheridan-methven8906
@oliversheridan-methven8906 День назад
Something comparing submodules with subtrees would be nice.
@kmacdowe
@kmacdowe День назад
Thanks! What kind of keyboard/mouse set up is that? It looks useful.
@JorgeAnais
@JorgeAnais День назад
I typically watch videos at 2x speed, but this time I'm watching at 0.5x speed.
@anthonywritescode
@anthonywritescode День назад
.5x speed but only 5% of the time?
@slavapasedko3139
@slavapasedko3139 День назад
Hi Anthony. Thank you for such great content. It’s really hard to find intermediate/advanced python topics on youtube because most of the content is created for beginners and there’s no point to watch it if you already have at least some production experience. Keep up the great work. I’d like to ask you to record a video about Python memory management, how to write cpu/ram efficient code, tips & tricks, what to avoid and all python memory-cpu-related stuff, memory leaks, profiling, etc. (I watched a video about preloading & gc.freeze() it was really fun and cool stuff you did.)
@anthonywritescode
@anthonywritescode День назад
it's difficult to pinpoint a strategy specifically -- at least when writing pure python you don't really have much control over it other than not globally caching things forever (and not using buggy C libraries!) -- that said here's a few others I've done about memory (explains videos are collected at github.com/anthonywritescode/explains) - using memray to debug a memory leak in krb5: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bw5AHdZA7e4.html - don't lru_cache a method: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sVjtp6tGo0g.html - fixing a 9GB memory leak in cargo: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-uxJhAXdBlbc.html
@senseikoudai6186
@senseikoudai6186 2 дня назад
Maybe an obvious question, but why were there two None values in the first place?
@slavapasedko3139
@slavapasedko3139 День назад
Generator can yield, return and accept value using .send() Hence three typings for each of those possibilities
@anthonywritescode
@anthonywritescode День назад
I cover this in the video linked in the description in more detail as well!
@bashirabdelwahed40
@bashirabdelwahed40 2 дня назад
oh finally!!!!!!
@hansdietrich1496
@hansdietrich1496 2 дня назад
Yeah, that always caused eye cancer.
@AceofSpades5757
@AceofSpades5757 3 дня назад
That's fantastic. It's ugly and most people don't understand the other 2 anyhow
@madhan1926
@madhan1926 3 дня назад
Is it possible to achieve git like functionality here? Like creating commit through one api, then using push api to push commits to github.
@anthonywritescode
@anthonywritescode 3 дня назад
that is... exactly what this video is?
@sillybuttons925
@sillybuttons925 3 дня назад
wow that is great. Always found that annoying.
@Quarky_
@Quarky_ 3 дня назад
Is there a difference between importing Generator from collections.abc and typing?
@iamcurrentlypooping
@iamcurrentlypooping 3 дня назад
typing.Generator is a deprecated alias to collections.abc.Generator
@Quarky_
@Quarky_ 3 дня назад
@@iamcurrentlypooping thanks! I was recently going through the docs, and I don't recall seeing any deprecation warning, that's why I was confused. Looks I just overlooked it :⁠-⁠P
@ArcRCG
@ArcRCG 3 дня назад
This is cool, this decorator-context manager equivalence reflects that a decorator what basically is doing is "managing" the "context" of the wrapped function and that a context manager is basically is "decorating" an annonymous IIFE. One really beautiful abstraction.
@bennyyouknow
@bennyyouknow 3 дня назад
Love your energy in this one 😊 Indeed a nice QoL improvement 🎉
@kRySt4LGaMeR
@kRySt4LGaMeR 3 дня назад
really cool, but it highlights how foreign type hints are to the core language
@bswck
@bswck 3 дня назад
So excited about that change. I often violated the rule of maximum specificity in the return type and simply used a higher-in-hierarchy `Iterator[T]`, which is obviously not an equivalent: it was only suitable for cases where I didn't have to access `.send()`, `.throw()` or `.close()`; but that was the majority of cases. Nevertheless, so cool I can just use `Generator[T]` now. There are lots of other use cases, for example `textual.App[T]` with the `T` defaulting to `None`.
@lukajeliciclux3074
@lukajeliciclux3074 3 дня назад
YESSSS!!!!! Generator[int,None,None] is just WHY?!
@guscardvs
@guscardvs 3 дня назад
This could be true for Coroutine also
@anthonywritescode
@anthonywritescode 3 дня назад
indeed! though I'm not sure Coroutine got the same treatment :(
@danielmajer1648
@danielmajer1648 3 дня назад
Everytime I write something else than python I wish it was python. Unfortunately mypy is still not standard for most of the folks like typescript
@ColtinC
@ColtinC 3 дня назад
This is my second favorite hackathon shirt! Eco Hack shirt finally beat it, but still a favorite. Very happy to see you still making these videos! RU-vid has not put them in my feed for awhile.
@DavidDellsperger
@DavidDellsperger 3 дня назад
alternative title: Nerd gets excited he doesn't have to type ", None" as often
@anthonywritescode
@anthonywritescode 3 дня назад
it's true!
@samuelgunter
@samuelgunter День назад
@@anthonywritescode isn't it True?
@ayhanfuat
@ayhanfuat 3 дня назад
It was so fun to watch you get happy about this. 😀
@flamendless
@flamendless 3 дня назад
696.... It is nice
@s-h-f
@s-h-f 3 дня назад
Didn't understand much as I am still a beginner. But seems like they get rid of ugly (unnecessary) annotations. Thanks for demo.
@bswck
@bswck 3 дня назад
annotations are beautiful, not ugly.
@victordvickie
@victordvickie 3 дня назад
I never seen a grown man more happy than this, good addition btw lol
@abrahammurciano
@abrahammurciano 3 дня назад
Generator[T, None, None] is one of those things that everyone knows about but most don't know why. It would be cool to have a video explaining what the other types are for
@anthonywritescode
@anthonywritescode 3 дня назад
I have one! I forgot to link it in the description but it's there now!
@abrahammurciano
@abrahammurciano 3 дня назад
This is exactly why I've always annotated my generators as Iterator[T]. Finally I can use Generator!
@bacon4life
@bacon4life 3 дня назад
Cool, I have dozens of Generator[T, None, None] in my projects.
@IleniaQuintero
@IleniaQuintero 5 дней назад
Hello, I was looking at your video channel. We may be helping a company that uses secure images to increase supply chain security and help cloud native development. Would you be willing to help try their software, make a video, and help show devs how to use their tools? This is not an offer, but just to start a conversation about your willingness to take on sponsorship. The video can be from 5 to 10 minutes long. You'd have a chance to look at their technology and decide if it's the type of software that you'd be interested in covering in your channel. Please provide us with your pricing.
@doodle3115
@doodle3115 6 дней назад
Hello Hello, I seem to be having an issue where the pro micro isn't entering programming mode. It's the same one you have linked in the readme, I have tried attaching a button and using a headphone jack. But windows never makes the noise and the terminal repeatedly gives me: avrdude ser_send() OS error: unable to write: Resource temporarily unavailable avrdude butterfly_vfy_cmd_sent() error: programmer did not respond to command: leave prog mode and then getting stuck on: avrdude butterfly_vfy_cmd_sent() error: programmer did not respond to command: exit bootloader Is this anything you might have words of wisdom for?
@anthonywritescode
@anthonywritescode 6 дней назад
you mentioned you're on windows -- are you working in a virtual machine like I am? you may need to add the usb device to the auto-attach list if you're using virtualbox (since the programming mode is a separate device itself) I've also had a similar error (though no idea if it's the same message) when I bricked a board -- though I would make sure to try a bunch of stuff first before getting a new one
@doodle3115
@doodle3115 5 дней назад
​@@anthonywritescode Alright, so the problem was entirely the auto-attach to vm thing. I've got it flashed now, shows up as a pokken controller and everything. That's my bad for missing something covered in the video. Thanks for your help.
@ccgarciab
@ccgarciab 6 дней назад
Not implemented seemed kinda normal to me. Isn't not implemented usually a bottom type in other type systems?
@RicchiMachado
@RicchiMachado 6 дней назад
I find the default stack level to be appropriate sometimes. For instance, during import time, if warning about some platform-specific idiosyncrasies related to the imported package in that environment.
@anthonywritescode
@anthonywritescode 6 дней назад
even in that case it would still be better at level=2 to warn about the place that imported it rather than the module with the warning -- it's trivial to track down where it's coming from in that case
@joaomcarlos
@joaomcarlos 6 дней назад
Hey, what if mix Protocol and TypeVar? Gave this a try and actually does not work. Example: ``` from typing import Protocol, TypeVar class IndexableProt(Protocol): def __index__(self) -> int: ... class C: def __index__(self) -> int: return 2 Indexable = TypeVar("Indexable", bound=IndexableProt) c = C() def print_indexable(i: Indexable): print("at i, val is: ", [1,2,3,4,5,6][i]) def print_indexable2(i: IndexableProt): print("at i, val is: ", [1,2,3,4,5,6][i]) print_indexable(c) print_indexable2(c) if isinstance(c, Indexable): print("yup") else: print("Nope") ```
@anthonywritescode
@anthonywritescode 6 дней назад
TypeVars can't be passed to `isinstance` -- otherwise that should work (though a TypeVar that's not used in the return value is sorta meaningless -- pyright will complain, mypy will allow it)
@v0id_d3m0n
@v0id_d3m0n 7 дней назад
Thanks. Great concise explanation. Thanks for explaining the use cases as well
@RoyAAD
@RoyAAD 8 дней назад
@4:40 you say this is a variance issue. Do you have a video that explains more about it?
@1234minecraft5678
@1234minecraft5678 9 дней назад
i think it is very weird, that -O sets __debug__ to false, which i would assume would be the normal behaviour. So you dont habe to enable debug, but disable it
@gardnmi
@gardnmi 10 дней назад
if not 0.0: print("python is a scripting languagle")
@hemanth8169
@hemanth8169 10 дней назад
Thank you! This was very helpful for me.
@TheRealisticNihilist
@TheRealisticNihilist 10 дней назад
Why is this guy using nano wtf?
@anthonywritescode
@anthonywritescode 10 дней назад
it's better than that :) check the header (nano is an alias because I haven't fixed my habits)
@XRay777
@XRay777 10 дней назад
I don't know how he does it but Anthony always manages to leave me speachless. Here I am thinking that I know Python quite well yet he always finds something to demo that makes me go O_o
@jamesarthurkimbell
@jamesarthurkimbell 10 дней назад
We must simply respond "fair enough"
@mrswats
@mrswats 10 дней назад
That's annoying. Is there a way to circumvent that somehow? I guess you could have tests that catch that but testing types in tests is not my favorite thing...
@anthonywritescode
@anthonywritescode 10 дней назад
you could maybe do something with NewType though I haven't found a reason that this detail breaks me yet to rationalize the complexity of NewType
@1rbroderi
@1rbroderi 9 дней назад
you can also use beartype which allows for type algebra and can easily define a float that isn't a int.
@Vic-ic7wi
@Vic-ic7wi 10 дней назад
NotImplementedType can be found in the types module (!= typing), along with other useful types (NoneType, EllipsisType, etc) :)
@bojandimic3914
@bojandimic3914 10 дней назад
Very nice video! False being a float I kinda expected but I honestly didn't know that the NotImplemented class existed.
@anthonywritescode
@anthonywritescode 10 дней назад
there's more about NotImplemented linked in the description too if you're further curious
@bojandimic3914
@bojandimic3914 10 дней назад
@@anthonywritescode I am sure I will get to it, I am currently at ~200th video of this playlist. It is very fun and informative to watch. :)
@Spitfire5592
@Spitfire5592 10 дней назад
What I wonder is, why have these quirks in the typing system instead of expecting __lt__ to raise NotImplementedError instead?
@lycantropos
@lycantropos 10 дней назад
to support other class instances as a right part of comparison/arithmetic operation that you don't know how to work with but they may know how ```python >>> 1 + MyNumberClass() ``` without `int` returning `NotImplemented` for `__add__` it won't be possible to use an overload in `MyNumberClass.__radd__` since `NotImplementedError` will be raised (and they can be raised by anything down the road while every function directly controls what it `return`s)
@anthonywritescode
@anthonywritescode 10 дней назад
I explained the reason for that at the end! (note that in addition to the reasons I state in the video it's not raising also, it's returning -- exceptions aren't part of the type system)
@Ash-qp2yw
@Ash-qp2yw 10 дней назад
So much of watching this for me is "That's weird... no, actually, that makes sense unfortunately"
@EinsteinNewtonify
@EinsteinNewtonify 11 дней назад
So there is no python built in way to handle that?
@Jakub1989YTb
@Jakub1989YTb 13 дней назад
Would the WikiDictionary be suitable for "registering" instances in a class variable for faster lookup later?
@santidelgado8088
@santidelgado8088 15 дней назад
thanks man I lov u
@bojandimic3914
@bojandimic3914 18 дней назад
I am very much enjoying your videos. Keep up the good work Anthony!
@yechielvizel
@yechielvizel 20 дней назад
I know it's an old video, but I just came across this situation where C() > D() And C doesn't know about D but D did know about C, Is there a way to type hinted it in a way that mypy will know it is valid C() < D() but not C() < SomeOtherClass()?
@anthonywritescode
@anthonywritescode 20 дней назад
not really, due to the way python is there aren't good mechanisms statically to know when things are comparable (besides well known ones like None which get special cased in the type system)