Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python SQLAlchemy Basics Working with SQLAlchemy Create and Read Books

Callum Anderson
Callum Anderson
9,414 Points

Ignored acception in console, continues to loop - SQLAlchemy/Pyhton

After adding my try block and ValueErrors which are working fine, but if I enter the response that should be accepted and continue the app to the next stage is instead looping the same request so I am unable to continue. Any help is appreciated this is really interesting so far and had loads of fun

I made a workspace to snapshot for ease:

https://w.trhou.se/2leylsp7r3

Many Thanks, Callum

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,464 Points

Hey Callum Anderson! The error is in the type comparison type(date) == datetime.date. The expression type(date) returns <class 'type'>. The comparison you wish to make is isinstance(date, datetime.date)

Additionally, date is not the best name for a local object since it can be confused with datetime.date in the case where it was imported using from datetime import date. Use a more descriptive name such as pub_date rather than just being a "date".

Post back if you need more help. Good luck!!

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi Callum Anderson! It should be if type(date_clean) and not if type(date). date_clean is holding the new, clean, DateTime version of the date the user passed in.