Ian Kelly <ian.g.ke...@gmail.com>:

> On Fri, Nov 20, 2015 at 5:28 AM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> One could argue that you should always use a sentinel object for
>> default values. That also allows you to distinguish between omitted
>> values and default values:
>>
>>    def asklist(caption, data, n=omitted, rows=omitted, width=omitted,
>>                flags=omitted, buttons=omitted, tablist=omitted,
>>                heading=omitted):
>>
>> but that would be rather pedantic in most circumstances.
>
> I think that would be bad design; in general, you shouldn't *need* to
> distinguish whether the value was omitted, because it should always be
> possible to explicitly pass the default value.

Consider the mutator pattern:

    def name(self, value=omitted):
        if value is omitted:
            return self._name
        self._name = value

    <URL: https://en.wikipedia.org/wiki/Mutator_method#C.2B.2B_example>


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to