![]() You can see which functions and variables are available with the dir() function Of course in most cases (desktop programs) the user can't do any more than they could do by writing their own python script, but in some applications (web apps, kiosk computers), this could be a risk. The user can expose hidden values in the program, or call a dangerous function ( dangerous_function("/etc/passwd")). In a large program this can potentially be quite dangerous. The user can type in an expression and it gets evaluated with different values of x. Print "x = ", x, ", y = ", eval(user_func) User_func = raw_input("type a function: y = ") It is used in Lybniz evaluate the functions input by the user. The eval function lets a python program run python code within itself. Using eval() safely in python Using eval() safely in python
0 Comments
Leave a Reply. |