[issue27661] Add tzinfo= argument to datetime.combine

Alexander Belopolsky report at bugs.python.org
Mon Aug 1 12:02:54 EDT 2016


Alexander Belopolsky added the comment:

>From review comments:

Lib/datetime.py:1482: def combine(cls, date, time, tzinfo=True):
On 2016/08/01 12:23:12, berkerpeksag wrote:
> On 2016/08/01 08:47:14, SilentGhost wrote:
> > This strikes me as an odd default value, why not use a more conventional
None?
> 
> Agreed. It would also be good to make it keyword-only.

tzinfo is not kw-only in the other constructors and I don't think it should be here.  Unlike "fold", tzinfo value is usually recognizable at the call site.  It is either called something like "tzinfo", "tz" or "New_York" or is a call such as 'tz.get('US/Eastern').

I would always prefer datetime.combine(d, t, tzinfo) to  datetime.combine(d, t, tzinfo=tzinfo).  datetime.combine(d, t, New_York) vs. datetime.combine(d, t, tzinfo=New_York) is a closer call, but still the first form is readable enough.


See <http://bugs.python.org/review/27661/diff/18026/Lib/datetime.py#newcode1482>.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27661>
_______________________________________


More information about the Python-bugs-list mailing list