TIL: Enforcing keyword-only arguments in Python function

You can enforce keyword-only arguments in your functions by adding “*” before the arguments. Example: def create_node(self, *, node_id, name): … When calling the above defined method, you will call it like: self.create_node(node_id=1, name=”node”) If you call self.create_node(1, “node”), it will raise a TypeError. I like that it makes my code look clean and makes …

TIL: Enforcing keyword-only arguments in Python function Read More »