4 ms·
> Python, as an example, really screws it up by not giving you a way to know if you have the default or a value that equals it. It does: set a unique `object()
by dxdm 6y ago
> Python, as an example, really screws it up by not giving you a way to know if you have the default or a value that equals it.
It does: set a unique `object()` instance as the default. It will only compare equal to itself, but it's even clearer to read if you check for identity with `is`. You'll need to define it outside of the function definition.
It's not the most concise, but it works, and it's an established pattern used in many high quality open source projects.
- taeric 6y agoThanks. This is kind of reinforcing my "not actually simple to use" point, though. :)