473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

passing keyword args as a parameter

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
2 1137
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Philips | last post by:
The following program passes parameters (inluding another function) into a function. def f(myfunc,m=3,*numbers): sumSquares=myfunc(*numbers) print sumSquares def sumofsquares(*args): total...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
5
by: blue | last post by:
We often get connection pooling errors saying that there are no available connections in the pool. I think the problem is that we are passing around open readers all over the place. I am...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
2
by: diffuser78 | last post by:
I wrote a small app in wxPython using wxGlade as designer tool. wxGlade brings and writes a lot of code by itself and thats where my confusion started. Its about parameter passing. Here is my...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
1
by: August Karlstrom | last post by:
Hi, In Perl you can pass the elements of an array to a function as actual parameters, for example my @a = (1, 2, 3); f(@a); which has the same effect as f(1, 2, 3). Does anyone know if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.