By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

passing keyword args as a parameter

P: n/a
hi there!

this post is somewhat a generalization of one previous question.

i was wondering if it is possible to pass an argument list as a
parameter to a function. example:

def fun_con_pc(pc1 = "Ciao!", pc2 = 42):
print pc1
print pc2

fun_con_pc()
fun_con_pc(pc1 = "Addio...")

fun_con_pc(pc2 = 666, pc1 = "Addio...")

arg = 'pc2 = 666, pc1 = "Addio..."'
fun_con_pc(arg)

.....

if i execute, i get:

Ciao!
42
Addio...
42
Addio...
666
pc2 = 666, pc1 = "Addio..."
42

**but** i want to get:

Ciao!
42
Addio...
42
Addio...
666
Addio...
666

.....

see what i mean?

bye

macs
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"max(01)*" <ma**@fisso.casa> wrote:
see what i mean?


not really, but maybe

arg = {"pc2": 666, "pc1": "Addio..."}
fun_con_pc(**arg)

is what you want?

</F>

Jul 18 '05 #2

P: n/a
Fredrik Lundh wrote:
"max(01)*" <ma**@fisso.casa> wrote:

see what i mean?

not really, but maybe

arg = {"pc2": 666, "pc1": "Addio..."}
fun_con_pc(**arg)

is what you want?


precisely! thanks a lot!

macs
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.