Xah Lee wrote: > i wanted to find out if Python supports eval. e.g. > > somecode='3+4' > print eval(somecode) # prints 7 > > in the 14 hundred pages of python doc, where am i supposed to find this > info? >
Option 1: As they say in the classics, "Suck it and see". If you want to find out if something is supported, just type it in: >>> somecode = '3+4' >>> eval(somecode) 7 >>> Option 2: Use help(): >>> help(eval) Help on built-in function eval in module __builtin__: eval(...) eval(source[, globals[, locals]]) -> value Evaluate the source in the context of globals and locals. The source may be a string representing a Python expression or a code object as returned by compile(). The globals must be a dictionary and locals can be any mappping, defaulting to the current globals and locals. If only globals is given, locals defaults to it. Option 3: If you have Windows, it's easy to find, just click on the Python documentation icon, then select the index tab, and type in "eval" (or whatever). Option 4: On the Python website, click on the docs link, then choose library reference manual, then either go to the built-in functions, or go to the index and select "eval" -- this latter method will take you to this link: http://www.python.org/doc/2.4.1/lib/built-in-funcs.html#l2h-23 HTH, John -- http://mail.python.org/mailman/listinfo/python-list