Your Call(able): Cool parts of python’s callable interface - Dom Weldon

preview_player
Показать описание
Functions are fundamental to python, and are amongst the first features of python that most users learn. We call a function with arguments, and it returns a value. However, there is more to this callable interface than meets the eye, and there are lots of useful and powerful (and cool!) things we can do with the callable interface. You may have come across many of these already: (anonymous) lambda functions, the __call__ magic method, the decorator pattern, the __doc__ property, and modules like functools and inspect which provide detailed about functions and allow us to alter functions at runtime. Lots of libraries, particularly web frameworks like Flask, Django, and FastAPI, and testing toolkits like pytest, use this callable interface to implement their API, and as developers, understanding these advanced features of python’s callable interface is particularly useful when writing generic, automation focused code. This talk gives a deep-dive into python functions, and the associated callable interface. We’ll start with quick tour of the basics, before covering python’s more advanced callable features. Finally, using an example – automatically generating FastAPI endpoints for dataclasses and SQLAlchemy models – we’ll see how and why we might want to use them.
Рекомендации по теме
Комментарии
Автор

I hope you will turn off autofocus on your camera from this year onward!

coolandsmartrr