PHP中文网2017-04-17 14:00:48
Okay~~I’m in over my head
If it’s just a function comparison, just use ==
But my situation here is a bit special
So I can only compare names
高洛峰2017-04-17 14:00:48
For user-defined functions, just compare the function's __code__
attribute (Python 3) to see if it is in the allowed list. As for the built-in functions, since you want to restrict them, you won’t allow users to load the C library, right? Then just compare the function addresses.
But don’t think that you can sit back and relax, it shouldn’t be difficult to bypass. For example, the sort function accepts a parameter as a function.