Python 比较两个函数是否一致
高洛峰
高洛峰 2017-04-17 13:58:48
0
3
689
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
洪涛

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

阿神

You can study the source code of pysandbox

小葫芦

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template