Skip to content
loading...

re: SLAP Your Functions! VIEW POST

TOP OF THREAD FULL DISCUSSION
re: This mental context switch makes it harder to read actually. Maybe, maybe not ... Consider: def tweet_to_html(tweet): res = re.sub(r"(^|\s...
 

the first could be written:

def tweet_to_html(tweet):
    //insert span around handle
    res = ...

Here the function is nothing more than specifying a name, you can do this in a comment

If you just add a comment, you still have to skim past all the implementation details to figure out what the function is intending to do. With this example this, since it's such a small function this isn't too burdensome but if the implementation is more complex, then that's a lot of noise to sift through to determine what the function does.

code of conduct - report abuse