Einenlum.

This Week I Learned: 2022W39

Mon Oct 03 2022

Swagger Editor

Swagger Editor sadly does not support OpenApi 3.1 until now (although it was released in February 2021).

Swagger - Code Generation

Swagger supports server code generation in many languages. Yes, I was today years old when I found out about it.

Another forked project is OpenApi Generator.

Sadly, both seem quite complicated to me (and Django is not supported).

Python - Assert

The second parameter to assert in Python, is the message to throw in the AssertionError.

a = 3
assert a < 0, "Sorry, a can't be greater than 0"

Python - Instructions

Python is really more flexible than other languages and it reads code line by line.

This is a perfectly valid piece of code (which for a PHP or Java developer is super weird):

class Foo:
    for i in range(10):
        # We create on the fly 10 methods from
        # fun_0 .. to fun_9
        locals()[f'fun_{i}'] = lambda self, x: x

obj = Foo()

obj.fun_3('hello') # 'hello'

Git - new commands

I just realized git has a switch command since some time (thanks Olivier for the discovery!).

git switch branchName is equivalent to git checkout branchName.

git switch -c branchName is equivalent to git checkout -b branchName.

Als found out about: git whatchanged --since="2 weeks ago". This is really cool.