### Learning Kotlin – Part 1 – print

Motivation I wanted to try writing an Android app. In spite of using plain old Java I wanted to give the new kid on the block Kotlin (from the Jetbrains folks) a try. First observations Coming from a Python background it’s good to see that Kotlin doesn’t use semi-colons! But the curly braces from Java…

### 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…

### Introduction to matplotlib – Part 2

When you finished reading part 1 of the introduction you might have wondered how to draw more than one line or curve into on plot. I will show you now. To make it a bit more interesting we generate two functions: sine and cosine. We generate our x-values with numpy’s linspace function import numpy as…

### 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

### 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…

### SQL – NULL-safe equals operator

<=> is the NULL-safe equals operator SELECT * FROM reports WHERE NOT driver <=> user_id