yeah, usually the workaround is to have items = None as the default, and then some kind of check at the top of the function like items = items if items else []
looking at it now I see why it's weird lol but you definitely get used to it
its probably for optimisation to reduce the amount of instructions needed to initiate a function call. On the plus side, its an easy place to define a cache
View all comments
Show parent comment
73
u/Xelanybor Oct 26 '26
yeah, usually the workaround is to have
items = Noneas the default, and then some kind of check at the top of the function likeitems = items if items else []looking at it now I see why it's weird lol but you definitely get used to it