NMarcu wrote: > Hello all, > I need some help to understand a getattr syntax. The syntax is: > > try: > getattr(self, command)(cursor, row) > except Exception, e: > print "Action failed : '%s'" % command > raise e > > I don't understand why is not like this: a = getattr(), and what are > the scope of the second (): (cursor, row)
The attribute in question is a callable, a method most probably. So getattr(self, command) returns a reference to the method, and the following (cursor, row) calls it with cursor and row as parameters. You could rewrite it as method = getattr(self, command) print method method(cursor, row) Diez -- http://mail.python.org/mailman/listinfo/python-list