attribute error
Mike Meyer
mwm at mired.org
Thu Sep 29 15:49:41 EDT 2005
In <433C4402.6050408 at grads.ece.mcmaster.ca>, M.N.A.Smadi <smadim2 at grads.ece.mcmaster.ca> typed:
> HI;
>
> I am having the following error:
>
> AttributeError: 'str' object has no attribute 'pop'
>
> am using Python 2.3.4 and am importing the following libraries:
>
> import sys, os, inspect
> from Asterisk import Manager, BaseException, Config
> import Asterisk.Util
>
> The code being executed is:
> if command not in commands:
> raise ArgumentsError('invalid arguments.')
>
>
>
> if command == 'usage':
> return usage(argv[0], sys.stdout)
>
> manager = Manager.Manager(*Config.Config().get_connection())
>
> if command == 'actions':
> show_actions()
>
> if command == 'help':
> if len(argv) < 3:
> raise ArgumentsError('please specify an action.')
>
> show_actions(argv[2])
>
> elif command == 'action':
> if len(argv) < 3:
> raise ArgumentsError('please specify an action.')
>
> try:
> execute_action(manager, argv[2:])
> except TypeError, e:
> print "Bad arguments specified. Help for %s:" % (argv[2],)
> show_actions(argv[2])
>
> elif command == 'command':
> execute_action('command', argv[2])
This should be execute_action('command', argv[2:]), with the ':' added.
<mike
> def execute_action(manager, argv):
> method_name = argv.pop(0).lower()
>
>
>
> but i always thought that something like this will be standard stuff.
> Any ideas?
>
>
> Mike Meyer wrote:
>
> >"M.N.A.Smadi" <smadim2 at grads.ece.mcmaster.ca> writes:
> >
> >
> >
> >>HI;
> >>
> >>I am having the following error. I am using someone else's code and
> >>all they are doing is pass an argv to a function then
> >>
> >>def execute_action(manager, argv):
> >> method_name = argv.pop(0).lower()
> >>
> >>
> >>and am getting this strange error.
> >>AttributeError: 'str' object has no attribute 'pop'
> >>
> >>am using Python 2.3.4 and am importing the following libraries:
> >>
> >>import sys, os, inspect
> >>from Asterisk import Manager, BaseException, Config
> >>import Asterisk.Util
> >>
> >>but i always thought that something like this will be standard stuff.
> >>Any ideas?
> >>
> >>
> >
> >Yes - show us the rest of the code. execute_action is never called in
> >the snippets you posted, and it's pretty clear that it's being invoked
> >with the wrong thing as an argument. Can you provide a minimal working
> >(well, executable) code sample that generates the error message you
> >are getting?
> >
> >Oh yeah - post the full traceback as well.
> >
> > <mike
> >
> >
> >
>
>
--
Mike Meyer <mwm at mired.org> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
More information about the Python-list
mailing list