eval function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ananth21
    New Member
    • Oct 2011
    • 13

    eval function

    what is and how to use eval function. here is what i read from a python text book, "a built-in function that treats a string as a piece of executable program code"
    i dont really know what an executable code is.
    kindly explain eval function with a little example so that i can understand better.
    thank you
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Following are 2 simple examples:
    Code:
    >>> eval("2*6")
    12
    >>> x = 100
    >>> eval('x')
    100
    >>>

    Comment

    Working...