3 ms·
Try it! The empty list in the first one is only created at the time the 'def' is executed. All subsequent calls to 'bad_append' hold the reference to this lis
by bockris 18y ago
Try it!
The empty list in the first one is only created at the time the 'def' is executed. All subsequent calls to 'bad_append' hold the reference to this list instead of a new empty one.
The 'good' one uses a sentinel value to indicate that you want to start with an empty list but also gives you the ability to pass in an existing one if needed.