Does everyone use ’s object() for unique tokens? Like:

no_match = object()val = some_dict.get('key', no_match)if val is not no_match:    do_something()

I don’t know what else object() would be used for (and why they’d keep it).

@2ck I do that sometimes.
It's kind of a historical fact now, I guess? At some point in py2 there wasn't "object" and then there was and you could opt-in to "new-style classes" with `class Foo(object):`. In py3 everything is new-style. IIRC ;)
#python

@meejah yeah, I mean specifically its use as a way to mint these sort-of do-nothing objects, not just its use as a type

@2ck I have certainly done that (and have seen it used).
There's also libraries like constantly.readthedocs.io/en/l for a similar use-case (but maybe .. a bit more "structured"?)
#python

Follow

@meejah that's kinda cool. If I ever used that though, I'd probably drop it the first chance I got in order to reduce dependencies. Would probably like it better as a code generation tool.

ยท ยท 0 ยท 0 ยท 1
Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.