Re: [Tutor] Calling a function by string name

2006-07-21 Thread Smith, Jeff
Title: Message Fantastic...that really did the trick!  I actually made one modification since p4python allows you to run Perforce commands by calling them with obj.run_COMMAND(args) so the final solution was:       def _p4run(self, method, *args):    'runs a Perforce command'    try

Re: [Tutor] Calling a function by string name

2006-07-21 Thread Michael P. Reilly
On 7/21/06, Smith, Jeff <[EMAIL PROTECTED]> wrote: I have an object and I want to call a method that I have constructed the name for in a string.   For example: str_method = 'myfun' obj.str_method   Of course, this fails.  I know I could probably do this with exec but is there a better

Re: [Tutor] Calling a function by string name

2006-07-21 Thread Kent Johnson
Smith, Jeff wrote: > I have an object and I want to call a method that I have constructed > the name for in a string. > > For example: > str_method = 'myfun' > obj.str_method > > Of course, this fails. I know I could probably do this with exec but > is there a better way? Use getattr(): get

[Tutor] Calling a function by string name

2006-07-21 Thread Smith, Jeff
Title: Message I have an object and I want to call a method that I have constructed the name for in a string.   For example: str_method = 'myfun' obj.str_method   Of course, this fails.  I know I could probably do this with exec but is there a better way?   For context, the specific appli