What is python pbr?

In Distributing your own package on PyPi I’ve talked about setuptools and twine to upload a package to the Python Package Index. PBR is a nice little add-on to simplify the setup and the deplyoment of your packages.

Python Argparse

Primer: Arguments vs Parameters I’m sometimes confused. Is it an argument or a parameter? So here it goes: A parameter is a variable in a function definition. When a function is called, the arguments are the data you pass into the function’s parameters. The same goes for a program: A program has parameters, you call…

pytest Tutorial – Part 3

Having your tests in place after reading pytest Tutorial – Part 1 and pytest Tutorial – Part 2 you certainly want to know how much of your code is actually tested by your tests. This is called coverage. Installation pip install pytest-cov Checking the coverage

pytest Tutorial – Part 2

In my last article pytest Tutorial Part 1  I showed some basic concepts of testing with pytest. Here are two additional concepts Parameterize Test parameterization follows the concept of DRY – Don’t repeat yourself Instead of writing a new testcase for every different value you annotate your test function and handover the different values. The…

Pandas Cheat Sheet

If you are new to Pandas feel free to read Introduction to Pandas I’ve assembled some pandas code snippets Reading Data Reading CSV import pandas as pd # read from csv df = pd.read_csv(“path_to_file”) Can also be textfiles. file suffix is ignored

New Blog Post

Sound and music with pygame

pip install pygame Sound import pygame if __name__ == ‘__main__’: pygame.mixer.init() sound = pygame.mixer.Sound(“./sound.wav”) channel = sound.play() while channel.get_busy(): pygame.time.wait(100) print(“Playing…”) print(“Finished.”)   Music import pygame if __name__ == ‘__main__’: pygame.mixer.init() pygame.mixer.music.load(“./sound.mp3”) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): pygame.time.wait(100) # ms print(“Playing…”) print(“Finished.”)

Python variable length arguments

Ever wondered what these *varargs or *kwargs in python functions parameter mean? Let me explain! varargs varargs is short for variable arguments. It is declared like this: def print_person_varargs(name, *vargs): pass You can pass as many arguments as you like. In this case we pass two after the first positional argument ‘name:’ print_person_varargs(“Jörn”, 40, “Emskirchen”)…

pytest Tutorial – Part 1

At PyConDE Berlin 2019 Florian Bruhin gave a really nice session about testing with pytest, which I try to recap here. Writing Tests If You want to work with pytest you can install it via: pip install pytest When you know basic python unittest fixtures, good news ahead: pytest is compatible and will run your…

Software Testing Concepts

My Tale of Woe When I graduated from university and had my first job as a software engineer at Harman Becker Automotive Systems GmbH I should do the parental leave cover for a colleague. He showed me his project, gave me some info e.g. contact person and went off to Canada. Literally on the second…

Python Package parameterized

Stackoverflowing around I found this nice package https://github.com/wolever/parameterized Parameterized testing in Python sucks. parameterized fixes that. For everything. Parameterized testing for nose, parameterized testing for py.test, parameterized testing for unittest. Reading this description I had very high expectations 🙂 So let’s see if the package can hold up to it.