question od default args
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Wed Jun 26 14:03:08 EDT 2002
On Wed, 26 Jun 2002 17:50:42 GMT, Hans Nowak <wurmy at earthlink.net>
wrote:
>Gonçalo Rodrigues wrote:
>> Hi,
>>
>> When I want default args I usually do
>>
>> def (arg = None):
>> ...
>>
>> But what if I want to make None a reasonable argument too? That is, I
>> want to know if the user has in fact passed an argument, and if not to
>> do something special, with None (or whatever object) being a reasonable
>> arg to be passed.
>
>Hmm, so use a default argument that is not reasonable to pass... some weird
>string, or a complex number, or even an instance of a (singleton?) class
>written especially for this... although that may be a bit overkill. Of course,
>the question is what is "reasonable" here and what not...
In principle everything is reasonable. But (some variation of) "an
instance of a (singleton?) class written especially for this" is worth a
try.
Thanx,
Gonçalo Rodrigues
More information about the Python-list
mailing list