Skip to content

Comments

init commit.#2

Open
rchagolla wants to merge 1 commit intocst438-team13:mainfrom
rchagolla:rolando-solution
Open

init commit.#2
rchagolla wants to merge 1 commit intocst438-team13:mainfrom
rchagolla:rolando-solution

Conversation

@rchagolla
Copy link

No description provided.

print(f'Users in {state}: {usersInState}\n')

# main program loop
def runProgram():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good separating into functions, your main loop is way cleaner than mine



def main():
runProgram()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly redundant? Could rename runProgram->main

hits = []
for user in users:
if user.state == state:
hits.append(user.displayName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice combination of try/catch and recursion

print('Access Permitted\n')
break
else:
print('Access Denied\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do this at line 35 so you can pass it into the constructor?

return posts

# loading data from path
def loadInputData():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separating and using recursion in your functions makes your code very readable and efficient.

return None

def canViewPost(post, username):
if post.visibility == 'friend':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants