The first in a new monthly series of short talks for those in the research community at TUOS who
work with/write code,
use/manage research data and
use/manage research infrastructure.
We hope through these LuchBytes talks we as a come together as a community to discuss best practices and useful methods/tools.
Type hinting in Python
Joe Heffer, Research Data Engineer, IT Services
What on earth is that object?
Make your Python code more readable, for yourself and your collaborators,
reduce risk of incorrect inputs and increase your IDE productivity by
annotating your functions with type hints.
A Practical Introduction to pytest
David Jones, Research Software Engineer, RSE team
You can test your Python code with pytest, one of the leading systems
for testing Python code.
Here I will gently introduce you to pytest with practical examples. As
pytest themselves put it pytest “helps you write better programs”.
Avoiding ‘side effects’: writing functions that are easier to test
Will Furnass, Research Software Engineer, RSE team
Everyone who writes code needs to consider if/when/how to encapsulate
code as functions.
But what makes for a good function that you can test/validate? One
strategy is to try to write a proportion of your functions so they don’t
have ‘side effects’,
where a side effect is something like reading/writing a file or
reading/writing data over a network.
By creating functions that only return useful values and don’t perform side effects functions can be much easier to test.
Here we discuss why, when and when not to write functions without side effects.
This talk should be of interest to those who write Python code and code in other languages.