New submission from Alexander Belopolsky <belopol...@users.sourceforge.net>:

Prior to r82454, python implementation of timedelta had the following comment:

class timedelta:
     def __new__(cls, days=0, seconds=0, microseconds=0,
                 # XXX The following should only be used as keyword args:       
 
                 milliseconds=0, minutes=0, hours=0, weeks=0):


This suggests that these arguments were intended to be keyword only, but at the 
time there was no language support for that.

In 3.x, the above can be rewritten as

class timedelta:
     def __new__(cls, days=0, seconds=0, microseconds=0, *,
                 milliseconds=0, minutes=0, hours=0, weeks=0):

to require that milliseconds, minutes, etc, be used only positionally.

This would be a backward incompatible change, so it would need to go through a 
deprecation process, but I think someone writing

HOUR = timedelta(0, 0, 0, 0, 0, 1)

or

WEEK = timedelta(0, 0, 0, 0, 0, 0, 1)

deserves a deprecation warning.

----------
assignee: belopolsky
messages: 109339
nosy: belopolsky, mark.dickinson, pitrou, tim_one
priority: normal
severity: normal
stage: unit test needed
status: open
title: Deprecate use of more than 3 positional arguments in timedelta 
constructor
type: feature request
versions: Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9169>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to