by DasIch · 14y ago · 0 comments
NotSet = type("NotSet", (object, ), dict(__repr__=lambda self: "NotSet"))
There is no amazing concept, no new idea or even anything remotely interesting at all here. This is but a side-effect of a type system that encourages the usage of None in this way and the fact that None is generally used to mean undefined in keyword arguments.Why would anyone consider this notable, useful or even important enough to warrant an upvote?
The aspect that interests me is that this is a problem that crops up occasionally in different Python projects and there doesn't seem to be a recognized best-practice for addressing it.
(The `kwargs` approach seems like the most common but has all the downsides I mentioned.)