how to execute self.eval(xxx)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • firmlyjin
    New Member
    • Apr 2010
    • 3

    how to execute self.eval(xxx)

    how to execute self.eval(xxx)?
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    If you want to execute a string then exec(string). If you want to evaluate a string, then eval(string).

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      Originally posted by firmlyjin
      sorry,maybe my english some poor

      how to execute self.eval(xxx)?
      You question is too vague. Object self implies an instance where eval() would be a method. Built-in function eval() works like this:
      Code:
      >>> eval("[1,2,3]")
      [1, 2, 3]
      >>>

      Comment

      • firmlyjin
        New Member
        • Apr 2010
        • 3

        #4
        thanks everybody.

        manybe i don't correct to describle my question,becase my english poor

        my means is: self. + one_function,bu t the function is a string.so i try to self.eval(one_f unction),but the self tell me that no eval
        now,i try it: function = 'self.' + one_funciton,th en eval(function), it's ok

        thanks

        Comment

        Working...