Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Datetime not working correctly

Hi there

https://teamtreehouse.com/library/dates-and-times-in-python/manipulating-time-already

import datetime dir(datetime) ['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'spec']

Why am I not getting the same answer as the teacher, I'm using VS code. Regards, Gabriel

1 Answer

Travis Alstrand
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Travis Alstrand
Treehouse Teacher

Hey there Gabriel Guerra !

I just tested what the instructor did within workspaces and within my terminal in VS Code to see what results I get and in both cases I got exactly what the instructor got.

>>> import datetime
>>> dir(datetime)
['MAXYEAR', 'MINYEAR', 'UTC', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'date', 'datetime', 'datetime_CAPI', 'sys', 'time', 'timedelta', 'timezone', 'tzinfo']

I thought maybe it would be version difference, but I'm not exactly sure why you were getting the results you did.

Be sure to open the Python REPL when trying this.

If you'd like, you can write out the exact steps you performed to get these results, maybe we can figure this out :smiley:

hi Travis, I named my file datetime and it works now after renaming it. thanks ;)