This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: datetime.replace could take a dict
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger, tlynn
Priority: low Keywords:

Created on 2005-09-20 16:56 by tlynn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg54617 - (view) Author: Tom Lynn (tlynn) Date: 2005-09-20 16:56
Python 2.4.1.

datetime.replace uses its kwargs to specify the fields,
which I found a bit surprising.  It could also take an
equivalent dict.  (Failing that, it could have a fuller
docstring.)

What I was actually trying to do was round to the
nearest half hour.  floor and ceil methods taking a
timedelta would be nice too.
msg54618 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-10-16 02:20
Logged In: YES 
user_id=80475

Any function accepting keyword arguments can already be
called with an equivalent dict using the ** notation
(similar to tuple unpacking):

>>> from datetime import date
>>> d = dict(day=26, year=2004)
>>> date(2001, 1, 2).replace(**d)
datetime.date(2004, 1, 26)
History
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42391
2005-09-20 16:56:29tlynncreate