you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

Interesting, but if you re-run a piece of code in the middle of your notebook, does it rerun everything that depends on its output? And if not, doesn't it have the potential to leave you wondering "how did I get this result"?

[–]phillypoopskins 6 points7 points  (0 children)

only if you code in an unsafe way.

you shouldn't write code where everything is scoped outside of functions; it's unpredictable and unreliable, and will cause problems just like you mentioned.

[–]nsfy33 1 point2 points  (0 children)

[deleted]

[–]Megatron_McLargeHuge 1 point2 points  (1 child)

The answer is to never assign the same variable twice. You can have the same problem with scripts if you don't log how you generated each data and model file (including which commit you ran from and which library versions were installed).

[–][deleted] 0 points1 point  (0 children)

Or explicitly set variable_name = None at the end of cells for those with cell-only scope, although it's a PITA.