PyConDE Berlin 2019

I’ve always wanted to go to a conference and with PyConDE I’ve found one that suited me well: The price point of 300 bucks for 3 days of conference, 2 days of workshops and the opportunity to go to Berlin and visit my friend Thomas was fascinating!

Flask 1.1 is here!

From the flask release notes: Returning a dict from a view function will produce a JSON response. This makes it even easier to get started building an API. To get a minimal REST-Api all you have to do is: from flask import Flask app = Flask(__name__) @app.route(‘/return_dict’, methods=[‘GET’]) def return_dict(): return {“x”: “1”} if __name__…

Overcoming PyInstaller Pitfalls

When using PyInstaller to package an application to a self-containing bundle you might run into some pitfalls: Pitfall 1: PyInstaller overwrites spec file The first time you run pyinstaller you run it with pyi-makespec my_module.py instead of pyinstaller my_module.py pyi-makespec will generate a my_module.spec which you can alter. Afterwards you just ran pyinstaller my_module.spec to…

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…

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…