Feature Requests item #1296581, was opened at 2005-09-20 11:56 Message generated for change (Comment added) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1296581&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open >Resolution: Invalid Priority: 1 Submitted By: Tom Lynn (tlynn) Assigned to: Nobody/Anonymous (nobody) Summary: datetime.replace could take a dict Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Raymond Hettinger (rhettinger) Date: 2005-10-15 21:20 Message: 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) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1296581&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com