On Fri, 19 Jun 2009 14:36:01 +0100, Matthew Wilson <[email protected]> wrote:
On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote:if c == "today": c = datetime.today()Now I guess that you actually intend c to be passed as a datetime object. You only used the string as a type annotation, not as a real default value. Something like 'record_date = None' is better.Thanks for the feedback. I think I should have used a more obvious string in my original example and a more descriptive parameter name. So, pretend that instead of c="today" I wrote record_date="defaults to today's date". I know my way is unorthodox, but I think it is a little bit more obvious to the reader than record_date=None The None is a signal to use a default value, but that is only apparent after reading the code.
It's a very common idiom, however, and in addition record_data is None is a cheap test, while record_data == "defaults to today's date" is an expensive test as well as easy to mistype. -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
