On Fri, Jan 17, 2020 at 9:17 AM Python <python@python.invalid> wrote: > > Le 16/01/2020 à 11:56, samna...@gmail.com a écrit : > > On Wednesday, 15 January 2020 17:09:56 UTC, Python wrote: > >> Le 15/01/2020 à 16:34, andersh...@gmail.com a écrit : > >>> Thanks! > >> > >> Do not try it, though, with a expression such as > >> import os; os.system('rm -rf ~/*'). > > > > If you want something safer, https://github.com/pydata/numexpr has an > > expression function that will do the same thing. > > > > Another, safer : > > s = "42 + 5 * 12" > float(eval(f"f'{{{s}}}'")) > 102.0 > > Is it absolutely safe though? >
I'm extremely confused as to how this is safer. It's the exact same eval call, wrapped up in unnecessary conversions between string and float. ChrisA -- https://mail.python.org/mailman/listinfo/python-list