Get the latest tech news

Demystifying decorators: They don't need to be cryptic


"What on Earth is going on with decorators?" Is this you? They're not as hard as you think. But we need to get there step by step

There's the danger that another part of your code tries to access and modify this list, leading to bugs and unexpected behaviour: It decorates the print() function—the adornment, in this case, is the ability of the main program to keep track of all the arguments passed to the new function. However, the last line in the output shows you that the arguments you pass to separate calls of the decorated function are stored in a common list.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of decorators

decorators