Python slicing out of bounds never crashes

Indexing data[100] on a 3-element list crashes with IndexError, but slicing data[100:] returns an empty list with no error. Python silently clamps slice indices to the valid range. You can slice with absurdly large numbers and Python just gives you what it can.

#pythonweirdestlogic #pythonweirdbehavior #pythongotcha #pythontrick #pythonmindblown #pythonunexpected #pythonwtf #pythonhiddenfeature #pythonco...

https://www.youtube.com/watch?v=FgPkpyahr4k

Python slicing out of bounds never crashes #pythonlistbounds

YouTube

This Python function ignores try and except and always returns finally

When try, except, and finally all have return statements, finally always wins. Python guarantees finally blocks execute no matter what. The return in finally overwrites whatever try was about to return. Three return statements, only one actually returns.

#pythonweirdestlogic #pythonweirdbehavior #pythongotcha #pythontrick #pythonmindblown #pythonunexpected #pythonwtf #pythonhi...

https://www.youtube.com/watch?v=MDOqaOzK940

This Python function ignores try and except and always returns finally #pythongotcha

YouTube