I am wondering if there is a simple way to avoid using eval for the following code:
eval('6001 >= 6005') I have been searching for a couple hours trying to find a simple alternative after learning eval is not good practice, especially when you don't know who is going to be using the program.
The background to my use of this is something like this:
each of the two comparison variables will be a value from a pandas dataframe column, so it could also look like this:
eval('"my_city_name" == "your_city_name"') Any help is greatly appreciated! Thanks
queryand boolean indexing. You need to show a sample input-output though.pd.eval("os.remove('text.txt')")with an error ofWindowsError: [Error 2] The system cannot find the file specified: 'text.txt', so I'm not sure how safe it is