4 ms·
> Someone else might actually want os.path to change between call. Who? Why?
by cwyers 10y ago
> Someone else might actually want os.path to change between call.
Who? Why?
- zardeh 10y agoMonkeypatching for debugging, mocking, etc. Most of those are rare, but feasible. Monkeypatching a global as a side effect even rarer, but I think I've done it at some point.
- fovc 10y agoThe os.path is not a great example, but imagine a loop where inside the body you mutate some state of an instance and then directly access it. Compare the following with the os.path example: for animal in circus.animals: circus.next_free_clown.assign(animal) # circus.next_free_clown changes in every iteration