How best to test functions which use date.today
Christian Heimes
lists at cheimes.de
Sat Feb 28 13:39:35 EST 2009
Lie Ryan wrote:
>> But this fails with:
>>
>> TypeError: can't set attributes of built-in/extension type
>> 'datetime.date'
>
> This is because today is an attribute. In python, we can override
> attribute access to become a function call. I don't have python right
> now, but try this:
>
> del date.today
> date.today = mytoday
It won't work. The datetime module is written in C. You can't modify a C
extension.
Christian
More information about the Python-list
mailing list