Python Protocols

In my article Python Type Checking I wrote about type hints. Type hints are around the block since Python 3.5. Python 3.7 introduced another interesting concept to make Python code even more type safe: Protocols Duck typing If it walks like a duck and it quacks like a duck, then it must be a duck…

SQL-Basics: Relations

As the Junior Data Scientist of Knight Industries we created a table to keep track of all our operatives: SQL-Basics: Create, Read, Update, Delete Devon asks us to keep track of our operations aka missions as well. For the first implementation let us assume that a mission has one operative and an operative can participate…

SQL-Functions – SQL-Basics 3

In SQL-Basics we learned the standard SQL statements to create a table, insert data into it, retrieving data from tables and altering data. Now we want to do even Devon is a data driven man and to evaluate our mission, he likes to know from us: how many missions we finished the total cost of…

Distributing your own package on PyPi – Part 2

In Distributing your own package on PyPi I wrote about my first package on PyPI. Here are some refinements aka lessons learned: Project Description on PyPI I wondered why the project description on PyPi was empty. Solution: You need a long_description. If You already have a README.md, you can read it into a string and…

New Blog Post

Python datetime and format

One of the things I always forget is date and time in Python. So message to myself: The strftime method is used for formatting (string_format_time) import datetime start_date = datetime.datetime.now() DATE_FORMAT = ‘%d/%m/%Y %H:%M’ print(start_date.strftime(DATE_FORMAT)) Her is a nice little Cheatsheet

New Blog Post

Python3: ChainMap

Since Python 3.3 You can chain dictionaries which contain the same key in a prioritized order: from collections import ChainMap prio_1 = {“param_1”: “foo”} prio_2 = {“param_1”: “foobar”, “param_2”: “bar”} combined = ChainMap(prio_1, prio_2) print(combined[“param_1”]) # outputs ‘foo’ print(combined[“param_2”]) # outputs ‘bar’ The param_1 from the prio_1 dictionary is dominant, so it isn’t overwritten by…