Is it explicitly specified?

Diez B. Roggisch deets at nospam.web.de
Sun Feb 3 09:53:00 EST 2008


Bjoern Schliessmann schrieb:
> mario ruggier wrote:
> 
>> It may sometimes be useful to make use of the conceptual
>> difference between these two cases, that is that in one case the
>> user did not specify any key and in the other the user explicitly
>> specified the key to be None.
> 
> Do you have an example where this might be useful?

Any situation in which there would otherwise lots of documentation 
needed to inform the user that the sentinel value is something else than 
None.

Take something like this as an example:

def update_user(some, values, nullable_value=sentinel):
     # first, work with some and values
     ...
     # then, on something actually being passed to nullable_value
     if nullable_value is not sentinel:
        connection.cursor().execute("update table set value = ?", 
nullable_value)



I've seen this before, in code from e.g. Alex Martelli.

Diez



More information about the Python-list mailing list