is there any way to prevent side effects in python?

后端 未结 7 2016
别跟我提以往
别跟我提以往 2021-02-05 15:14

Is there any way to prevent side effects in python? For example, the following function has a side effect, is there any keyword or any other way to have the python complain abou

7条回答
  •  粉色の甜心
    2021-02-05 16:03

    Since any Python code can do IO, any Python code could launch intercontinental ballistic missiles (and I'd consider launching ICBMs to be a fairly catastrophic side effect for most purposes).

    The only way to avoid side effects is to not use Python code in the first place but rather data - i.e. you end up creating a domain specific language which disallows side effects, and a Python interpreter which executes programs of that language.

提交回复
热议问题