Conversation
| print(f'Users in {state}: {usersInState}\n') | ||
|
|
||
| # main program loop | ||
| def runProgram(): |
There was a problem hiding this comment.
Good separating into functions, your main loop is way cleaner than mine
|
|
||
|
|
||
| def main(): | ||
| runProgram() |
There was a problem hiding this comment.
Possibly redundant? Could rename runProgram->main
| hits = [] | ||
| for user in users: | ||
| if user.state == state: | ||
| hits.append(user.displayName) |
There was a problem hiding this comment.
Could use list comprehension here - off the top of my head I think it would look something like
hits = [user.displayName for user in users if user.state == state]| posts = processPosts(postFile) | ||
| except: | ||
| print('could not find file') | ||
| loadInputData() |
There was a problem hiding this comment.
Nice combination of try/catch and recursion
| print('Access Permitted\n') | ||
| break | ||
| else: | ||
| print('Access Denied\n') |
There was a problem hiding this comment.
Could rewrite as
print('Access Permitted\n' if canViewPost(post, username) else 'Access Denied\n')| # adds friends to user | ||
| friendSection = userSplit[3].strip('[]\n') | ||
| friends = friendSection.split(',') | ||
| user.addFriends(friends) |
There was a problem hiding this comment.
Why not do this at line 35 so you can pass it into the constructor?
| return posts | ||
|
|
||
| # loading data from path | ||
| def loadInputData(): |
There was a problem hiding this comment.
Separating and using recursion in your functions makes your code very readable and efficient.
| return None | ||
|
|
||
| def canViewPost(post, username): | ||
| if post.visibility == 'friend': |
There was a problem hiding this comment.
I like your use of Python as it allows for much simpler code than C++ when working with methods for classes. Will remember this next time for similar projects
No description provided.