On Aug 27, 2019, at 10:38, Nick Timkovich <[email protected]> wrote: > > Currently the datetime docs say: > > > An object of type time or datetime may be naive or aware. A datetime object > > d is aware if d.tzinfo is not None and d.tzinfo.utcoffset(d) does not > > return None. If d.tzinfo is None, or if d.tzinfo is not None but > > d.tzinfo.utcoffset(d) returns None, d is naive. A time object t is aware if > > t.tzinfo is not None and t.tzinfo.utcoffset(None) does not return None. > > Otherwise, t is naive. > > > https://docs.python.org/3/library/datetime.html#available-types > > Would an issue/PR be welcome to encode that logic into code? The docs could > then read: > > > An object of type time or datetime may be naive or aware. Aware objects > > have their "aware/tzaware/tz_aware" attribute set to True, and if naive: > > False.
Would this be a normal attribute that you always set at construction time? (Does that cause performance problems for aware datetime objects that never check the awareness?) Or is it a property that’s computed on the fly? If the latter, why a property rather than a method? What happens if utcoffset raises NotImplementedError? (Or anything else, I suppose, but NotImplementedError is the documented behavior for the base class.) Should date get an attribute that’s always False, or is it sufficiently obvious to most people that dates are always naive?
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/SCST3KUMFRFBELQXEHYNSQBIOQYAAYWF/ Code of Conduct: http://python.org/psf/codeofconduct/
