Conversation
spitsfire
left a comment
There was a problem hiding this comment.
Nicely done, Lily! Great job passing all tests!
I've added some feedback throughout your project to point out some places we can refactor in order to follow common conventions and standard practices when it comes to Python.
Things to consider as you work on future projects:
- Get used to putting your edge case conditionals (aka guard clauses) at the tippy top of your functions.
- Stay consistent with your syntax. When assigning in Python, it is most common to put a space before and after the
=sign.
|
|
||
| from viewing_party.party import * | ||
| from dataclasses import dataclass | ||
| #from symbol import subscript | ||
| from xml.dom import UserDataHandler | ||
|
|
There was a problem hiding this comment.
I don't think we need any of these imported packages. Sometimes VSCode tried to help us by auto-importing these lines when they think we are trying to type. Sometimes VSCode gets it very wrong.
Let's remove all of these
| from viewing_party.party import * | |
| from dataclasses import dataclass | |
| #from symbol import subscript | |
| from xml.dom import UserDataHandler | |
| movie_dictionary = {} | ||
| if title and genre and rating: | ||
| movie_dictionary["title"] = title | ||
| movie_dictionary["genre"] = genre | ||
| movie_dictionary["rating"] = rating | ||
| return movie_dictionary | ||
|
|
||
| else: | ||
| return None |
There was a problem hiding this comment.
nice job! 👍 I'd suggest flipping the sense of the condition around to handle the special case (that something is falsy) quickly and get out, rather than having that dangling else at the end. This arrangement is referred to as a guard clause or a guard condition.
Notice that it lets us move the main focus of the function (creating the new dict) out of an indented block, letting it stand out more clearly.
def create_movie(movie_title, genre, rating):
if not movie_title or not genre or not rating:
return None
movie_dict = {'title':movie_title, 'genre':genre, 'rating':rating}
return movie_dict| return None | ||
|
|
||
| def add_to_watched(user_data, movie): | ||
|
|
There was a problem hiding this comment.
make sure there are no blank lines between the function signature and the first indented line:
| #"watched": [{"title": "{movie} "genre": "Horror", "rating": 3.5}, | ||
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}, | ||
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}] |
There was a problem hiding this comment.
let's get rid of any commented out code or test data we don't need when we turn in our final submission
| #"watched": [{"title": "{movie} "genre": "Horror", "rating": 3.5}, | |
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}, | |
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}] |
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}, | ||
| # {"title": "Title A", "genre": "Horror", "rating": 3.5}] | ||
|
|
||
| def add_to_watchlist(user_data, movie): |
| def get_new_rec_by_genre(user_data): | ||
| recommended= [] | ||
| friends_movies = get_friends_unique_watched(user_data) | ||
| user_most_watched= get_most_watched_genre(user_data) |
There was a problem hiding this comment.
| user_most_watched= get_most_watched_genre(user_data) | |
| user_most_watched = get_most_watched_genre(user_data) | |
| return recommended | ||
|
|
||
| def get_rec_from_favorites(user_data): | ||
| recommended= [] |
There was a problem hiding this comment.
| recommended= [] | |
| recommended = [] | |
| recommended.append(movie) | ||
| return recommended | ||
|
|
||
| def get_rec_from_favorites(user_data): |
| # ------------- WAVE 5 -------------------- | ||
| # ----------------------------------------- | ||
|
|
||
| def get_new_rec_by_genre(user_data): |
| # ------------- WAVE 4 -------------------- | ||
| # ----------------------------------------- | ||
|
|
||
| def get_available_recs(user_data): |
Hi Claire I will try to fix this by Saturday 9/24/2022! thank you.