4 ms·
>There is a builtin function called `reversed`. You'd better remember that than the "useful" [::-1] idiom. Reversed produces an iterator and not a copy with al
by heretohelp 14y ago
>There is a builtin function called `reversed`. You'd better remember that than the "useful" [::-1] idiom.
Reversed produces an iterator and not a copy with all the dangers of mutable semantics. The [::-1] syntax is not equivalent as it returns a copy of the list as if it were reversed, changing up somewhat what it's doing.
You'd better remember that you should know what you're talking about before you start dictating to other people how they should write their code.