Pycon Israel 2021

"Clippy" for Python - Let's build a real-time code companion by hooking over any function.
2021-05-03, 16:00–16:45, PyData Track 1

Python can do so much, including using python to change python behavior. In this talk, we will see how we can hook over any function in order to create an online “helper” in the style of Clippy for the old Office software. This can be useful for refe

This talk stems from the package I've built dovpanda. dovpanda is an overlay companion for working with pandas in an analysis environment - it hooks over any pandas method and suggests better ways code. We use sys.modules to replace the original function with a modified version while keeping track of the originals using contextmanagers. We then use inspect to understand what parameters were sent by the user so we can employ them to the companion's benefit. Using ast the companion can also understand information about runtime such as checking whether the function call was used in an assignment or part of a complex statement.
Python is so wonderful, as it lets you control Python itself. This really feels like superpowers. In this talk I hope to scratch the surface of a few examples for such superpowers.

Session language – English Target audience – Developers, DevOps, Data Scientists, R&D