Modifying parent variables in python - Don't do this!

Published: 24 October 2022
on channel: InvalidEntry
134
5

A request from a viewer on how to modify variables in the callers scope - its doable, but it has a lot of bad reasons why you should. Python has a super open scope, which allows you to interact with both the variables and code of other objects. Its flexibility makes it super good for writing easy to read business logic, but can have issues if trying to write high security applications.

Python is not the only language which suffers - most other high level languages also contain features which allow the language to be turned against itself; they all contain the concept of stacks, frames, and usually through the exception system, allows a programmer to produce a reference to higher level languages.

This is not recommended though - it forms a tight coupling between the caller and callee, and will generally lead to un-usable sub functions (i.e. breaks the DRY pattern).


On this page of the site you can watch the video online Modifying parent variables in python - Don't do this! with a duration of hours minute second in good quality, which was uploaded by the user InvalidEntry 24 October 2022, share the link with friends and acquaintances, this video has already been watched 134 times on youtube and it was liked by 5 viewers. Enjoy your viewing!