Live data from Hacker News

Notset: A Do-Not-Care value for Python

github.com

1–10 of 41 posts

Re: Notset: A Do-Not-Care value for Python

#3

Sorry for the bikeshedding, but double negatives are a real pain. Not so much for the code itself, but for talking to colleagues and giving talks. Off the top of my head, Empty would could work.

Personally I would use "assigned" 1) to better reflect the meaning and 2) to follow PEP-8 and not use an uppercase.

Re: Notset: A Do-Not-Care value for Python

#4

Sorry for the bikeshedding, but double negatives are a real pain. Not so much for the code itself, but for talking to colleagues and giving talks. Off the top of my head, Empty would could work.

Agreed. 'Empty' works, as does 'Blank' or 'Unassigned'.'Nil' is concise, but might be a little too easily confused with 'None' (especially so for someone coming from Ruby).

I'd love an approach that used the standard library, but there doesn't seem to be a type-agnostic approach. float('nan') won't make sense for other types, and using `types.NoneType` instead of `None` seems even less understandable.

Re: Notset: A Do-Not-Care value for Python

#6
post #3

Sorry for the bikeshedding, but double negatives are a real pain. Not so much for the code itself, but for talking to colleagues and giving talks. Off the top of my head, Empty would could work.

Personally I would use "assigned" 1) to better reflect the meaning and 2) to follow PEP-8 and not use an uppercase.

Uppercase was chosen to match Python's existing singletons, `True`, `False`, and `None`. Lowercase might look a little too much like a variable, and all-upper might look too much like a module-level const, IMHO.

Re: Notset: A Do-Not-Care value for Python

#8
post #5

What's the difference to using "if name is not None:" in the first example?

That example could probably use some clarification, but the idea is that `name` and `age` in that example are both nullable, so passing in `None` (setting the column to NULL) is different than omitting the value (leaving the column unchanged).

Re: Notset: A Do-Not-Care value for Python

#9
post #5

What's the difference to using "if name is not None:" in the first example?

That example could probably use some clarification, but the idea is that `name` and `age` in that example are both nullable, so passing in `None` (setting the column to NULL) is different than omitting the value (leaving the column unchanged).

I think this could handled more elegantly if Python supported an Option type, by making 'name' an Option[Option[String]]

Re: Notset: A Do-Not-Care value for Python

#10

Sorry for the bikeshedding, but double negatives are a real pain. Not so much for the code itself, but for talking to colleagues and giving talks. Off the top of my head, Empty would could work.

I think I'd've gone for Unset. Empty's a bit close to None.
Post reply on HN