Changing calling sequence
David Raymond
David.Raymond at tomtom.com
Thu May 12 08:18:54 EDT 2022
>>def TempsOneDay(*dateComponents):
>> if len(dateComponents) == 3:
>> year, month, date = dateComponents
>> elif len(dateComponents) == 1 and isinstance(dateComponents[0], datetime.date):
>> year, month, date = (dateComponents[0].year, dateComponents[0].month, dateComponents[0].day)
>> else:
>> raise Exception("Error message here")
>
>|>>> help( TempsOneDay )
>|Help on function TempsOneDay in module __main__:
>|
>|TempsOneDay(*dateComponents)
Then just add an appropriate docstring.
>>> def TempsOneDay(*dateComponents):
... """Can be called either with 3 arguments: year, month, day
... or with a single datetime.date object"""
... if len(dateComponents) == 3:
... year, month, date = dateComponents
... elif len(dateComponents) == 1 and isinstance(dateComponents[0], datetime.date):
... year, month, date = (dateComponents[0].year, dateComponents[0].month, dateComponents[0].day)
... else:
... raise Exception("Error message here")
...
>>> help(TempsOneDay)
Help on function TempsOneDay in module __main__:
TempsOneDay(*dateComponents)
Can be called either with 3 arguments: year, month, day
or with a single datetime.date object
>>>
More information about the Python-list
mailing list