Why does Python have variable hoisting like Javascript?

I didn’t know those terms either. :slight_smile:

Anyway, on my bike ride today I realized that the key here is that Python uses function scopes – unlike C++, any variable defined anywhere in a function has that whole function as its scope.

It’s one of those things that make Python simpler than C++.

3 Likes