[Suggestion] Use an exception instead of None for assignment items

Quick suggestion, instead of using None for the placeholder value of things we are supposed to replace use a raised exception. That way you can also supply a helpful error message. E.g.
Instead of

    #{...}
    ### BEGIN SOLUTION - DO NOT delete this comment for grading purposes
    name=None, # Replace None
    feature_definitions=None, # Replace None
    ### END SOLUTION - DO NOT delete this comment for grading purposes
    #{...}

use something like

class AssignmentIncomplete(Exception):
   pass

def fill_me_in(error_msg):
    raise AssignmentIncomplete(error_msg)

then the fill-able part becomes

    #{...}
    ### BEGIN SOLUTION - DO NOT delete this comment for grading purposes
    name=fill_me_in("Give me a name!"), # Replace None
    feature_definitions=fill_me_in("Pass in the feature definitions defined above"), # Replace None
    ### END SOLUTION - DO NOT delete this comment for grading purposes
    #{...}

Just a quick quality of life improvement. Really enjoying this material.

I think that’s a great idea. The None can sometimes be missed. I spent well over an hour trying to figure out why my Athena query wouldn’t run (just said Internal Error), and it was because I had only replaced two out of three Nones.

@gathright and @memark:

Thank you for this great suggestion! I have faced sometimes similar situations when I also overlooked the “None”.

The DeepLearning.AI team is going to consider it for implementation and updates.

5 Likes