[issue9169] Deprecate use of more than 3 positional arguments in timedelta constructor

Antoine Pitrou report at bugs.python.org
Tue Jul 6 01:38:58 CEST 2010

Antoine Pitrou <pitrou at free.fr> added the comment:

> I would think that deprecating error-prone constructs is well within
> normal library evolution.  For example, several interfaces that
> accepted floats by truncating them to ints were deprecated in the
> past.

That's because silent truncation to int will lead to possible loss of
precision, or (worse) to poorly defined behaviour.
For example, if you call file.read(3.5), should it try to read 3 bytes
or 4 bytes? Deprecating such use is perfectly reasonable, because it
disambiguizes the API and avoids the use of a wrong type.

On the other hand, using positional arguments presents none of these
problems. There is no reason to deprecate it except your own aesthetical
preferences. Therefore I'm still -1.

> Has anyone seen (non-buggy) code in the wild that used > 3 positional
> arguments to timedelta?

Why do you think such code doesn't exist? It's not like timedelta() is
an extremely difficult API to use, even without keyword arguments.
Using Google Code Search, you will find snippets such as:

FIVE_MINUTES =  datetime.timedelta(0, 0, 0, 0, 5)


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list