From 'Barely Works' to Pythonic Code in 5 steps

Open link in next tab

From 'Barely Works' to Pythonic Code in 5 steps

https://www.youtube.com/watch?v=spi0N_PNznE

Writing code that "works" shouldn't be your end goal. It's really just the start...In this video, we adapt a clumsy, non-Pythonic API into an easy to use, ea...

In this video, we adapt a clumsy, non-Pythonic API into an easy to use, easy to understand Pythonic one. We use magic methods such as getitem_, len, enter, and _exit to make our objects a context manager and support the len() function and square bracket indexing. And in the end, we turn what once was ugly, difficult to maintain code into something that other developers would actually want to use.