Question about apply

2009-09-03 Thread jorma kala
Hi,
I'm using apply to pass keyword arguments as a dictionary  to a funcion at
runtime (which keyword arguments to pass is only known at runtime)
apply is very handy for this, because it takes a dictionary of keyword
arguments directly

def f1(a=None,b=None,c=None):
pass


kw={'a':1}

apply(f1,[],kw)

But I read in the doc that apply is deprecated.
What is the non-deprecated way of doing this?
Many thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about apply

2009-09-03 Thread Gary Herron

jorma kala wrote:


Hi,
I'm using apply to pass keyword arguments as a dictionary  to a 
funcion at runtime (which keyword arguments to pass is only known at 
runtime)
apply is very handy for this, because it takes a dictionary of keyword 
arguments directly


def f1(a=None,b=None,c=None):
pass
   
   
kw={'a':1}


apply(f1,[],kw)

But I read in the doc that apply is deprecated.
What is the non-deprecated way of doing this?
Many thanks



Use the double-star syntax:

f1(**kw)


Gary Herron

--
http://mail.python.org/mailman/listinfo/python-list


Re: Question about apply

2009-09-03 Thread jorma kala
Many thanks!!



On Thu, Sep 3, 2009 at 4:21 PM, Gary Herron gher...@islandtraining.comwrote:

  jorma kala wrote:


 Hi,
 I'm using apply to pass keyword arguments as a dictionary  to a funcion at
 runtime (which keyword arguments to pass is only known at runtime)
 apply is very handy for this, because it takes a dictionary of keyword
 arguments directly

 def f1(a=None,b=None,c=None):
pass
 kw={'a':1}

 apply(f1,[],kw)

 But I read in the doc that apply is deprecated.
 What is the non-deprecated way of doing this?
 Many thanks


 Use the double-star syntax:

 f1(**kw)


 Gary Herron


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about apply

2009-09-03 Thread MRAB

jorma kala wrote:

Hi,
I'm using apply to pass keyword arguments as a dictionary  to a funcion 
at runtime (which keyword arguments to pass is only known at runtime)
apply is very handy for this, because it takes a dictionary of keyword 
arguments directly


def f1(a=None,b=None,c=None):
pass
   
   
kw={'a':1}


apply(f1,[],kw)

But I read in the doc that apply is deprecated.
What is the non-deprecated way of doing this?


To pass a list as arguments use:

func(*arg_list)

To pass a dict as keyword arguments use:

func(**arg_dict)
--
http://mail.python.org/mailman/listinfo/python-list