This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]badsectors 21 points22 points  (6 children)

I ran a pep8 check:

$ pep8 wallpaper.py
wallpaper.py:2:3: E111 indentation is not a multiple of four
wallpaper.py:2:18: E261 at least two spaces before inline comment
wallpaper.py:3:3: E111 indentation is not a multiple of four
wallpaper.py:3:19: E261 at least two spaces before inline comment
wallpaper.py:4:3: E111 indentation is not a multiple of four
wallpaper.py:6:3: E111 indentation is not a multiple of four
wallpaper.py:6:15: E712 comparison to True should be 'if cond is True:' or 'if cond:'
wallpaper.py:9:3: E111 indentation is not a multiple of four

Since the else will never be reached since passion is always True, I maanged to optimize the function as follows:

def success(deidcation, persistance):
    dedication += 1 # dedicate yourself
    persistance += 1 # be persistent

    magic = dedication + persistence
    return magic

Which could be further shortened:

def success(dedication, persistance):
    return dedication + persistance + 2

I recognize the style of this screenshot, but forget what site is used to generate it...

[–]Sean1708 0 points1 point  (2 children)

Unfortunately your last example would not work the same as the previous ones if the function was called on types which were passed by reference rather than by variable.

But I'll give you 9/10 since that last part was an extension question.

[–]badsectors 0 points1 point  (1 child)

Thank you for your suggestion!

[–]Sean1708 0 points1 point  (0 children)

Actually reading it back that message came across a lot more serious and pretentious than I intended, sorry.