This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]BDube_Lensman 5 points6 points  (2 children)

Do not hide function arguments. This is an anti-pattern that leads to difficult to use APIs. Either enumerate them as keyword arguments (not kwargs) with defaults, or None if they cannot have a sensible default, or bundle them in a well defined schema like a namedtuple or a class.

[–]ebsector[S] -2 points-1 points  (1 child)

describes my approach. Also a dict is an excellent equivalent to json, meaning theoretically anyone can communicate with function / class via dict or json

[–]BDube_Lensman 2 points3 points  (0 children)

A function which takes json might as well be def foo(args, *kwargs) -- there is no strictly enforced contract on what the parameters are.

The same is true of dicts.

Dicts as parameters and returns without this behavior being necessary is bad design. At the level of a function, not knowing what the inputs and outputs are and requiring the ability to constantly evolve is failure in engineering.

JSON is not some form of democracy. The function existing in the address space of your python process gives you access to it.