Alex Martelli wrote:
> But this doesn't apply to the Python Standard Library, for example see
> line 1348 of imaplib.py: "if isinstance(date_time, (int, float)):".
[...]
> Being able to change imaplib to use basenumber instead of (int, float)
> won't make it SIMPLER, but it will surely make it BETTER -- why should
> a long be rejected, or a Decimal, for that matter?
Right. I think this function should read
if isinstance(date_time, str) and \
(date_time[0],date_time[-1]) == ('"','"'):
return date_time # Assume in correct format
if isinstance(date_time, (tuple, time.struct_time)):
tt = date_time
else:
tt = time.localtime(date_time)
If this is something that time.localtime can't handle, it will
give a TypeError. This is much better than
raise ValueError("date_time not of a known type")
# (why does it raise a ValueError if it says "type"?)
Regards,
Martin
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com