datetime.datetime. or datetime. ?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Oct 8 20:33:20 EDT 2009


En Thu, 08 Oct 2009 19:11:04 -0300, niklasr <niklasro at gmail.com> escribió:
> On Oct 8, 5:25 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>> NiklasRTZ schrieb:

>> > Hello, my basic question is which recommendation is after slight
>> > restructuring datetime.datetime to datetime

>>   - how to import is mostly a matter of taste, as long as you refrain
>> from using "from datetime import *"e
>
> type object 'datetime.datetime' has no attribute 'datetime' Traceback
> (most recent call last):
> is flexible, both ways worked just that self complying towards more
> professional projects naturally feels right. Above error log seemingly
> caused by import datetime instead of from datetime import datetime.

The datetime module doesn't contain anything useful apart from the five  
classes: date, time, datetime, timedelta and tzinfo. So using "from  
datetime import ..." is fine.

> Then changed import and cut the first datetime occurance which looks
> good but breaks next sync with other.

Just make sure to replace *all* occurrences of  "datetime.datetime" to  
"datetime", etc. Should be easy to do.
I don't know what you mean "breaks next sync with other".

-- 
Gabriel Genellina




More information about the Python-list mailing list