import arcpy tramples datetime import

Discussion created by flspat on Jul 14, 2016
Latest reply on Aug 28, 2017 by CDow-esristaff

I've never seen anything that states arcpy should/must be imported first in order to not override other system modules.  I only skimmed this document but didn't see anything specific, although their examples tend to imply it.  However if you do a import-from on datetime BEFORE importing arcpy, then you're datetime import will be destroyed:


>>> from datetime import datetime
>>> datetime.now()
datetime.datetime(2016, 7, 14, 12, 10, 12, 433000)
>>> import arcpy
>>> datetime.now()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'now'


Either import datetime after arcpy or use the import-from-as syntax and give datetime an alias.