A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/059849.html below:

[Python-Dev] basenumber redux

[Python-Dev] basenumber redux"Martin v. Löwis" martin at v.loewis.de
Wed Jan 18 00:21:13 CET 2006
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4