13 Jun
2016
13 Jun
'16
5:13 p.m.
(Riffing off some discussion in another thread, I had another idea I wanted to throw out there.) Given that Eval Really Is Dangerous[1], has something like this ever been considered?:
int(str(42)) 42 float(str(42.0)) 42.0 bool(str(False)) # :( True eval_literal('42') 42 eval_literal('42.0') 42.0 eval_literal('False') # :) False eval_literal('', default=False) # shout out to PEP 463 / Michael Selik False
i.e. An extremely limited version of eval, possibly just for literals or even literal atoms, that would make it safe? [1] http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
2845
Age (days ago)
2845
Last active (days ago)
5 comments
5 participants
participants (5)
-
Bar Harel
-
Chris Angelico
-
jab@math.brown.edu
-
Jelle Zijlstra
-
Mahmoud Hashemi