----- Original Message -----
> Thanks for that. It resolved the issue and it was so simple compared
> to everything else I saw on the net.
> 
> Only outstanding thing I have to work out is how to execute functions
> from a dictionary. I will continue searching on the net.
> 
> 
> Sean

This may help you (untested code)

class Workers:
  @staticmethod
  def ospf(*args, **kwargs):
    print args, kwargs
    return 'Bar'

  @staticmethod
  def bhp(*args, **kwargs):
    return 'Foo'

outputs = {'ospf' : {1 : {'param1' : 'foo', 'param2' : 'foo2'}}

for command, value in outputs.items():
  for counter, kwargs in value:
    func = getattr(Workers, command) # get the function
    func(**kwargs) # the actual call 

It would be possible to do it without the *args, **kwargs magic. You can write 
ospf and bhp with the explicit parameters, however you must make sure you pass 
the correct number of parameter in the call.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to