Hello,
Let's say I have a function with a variable number of arguments(please ignore syntax errors):
def myfunc(a,b,c,d,...):
and I have a tuple whose contents I want to pass to the function. The number of elements in the tuple will not always be the same.
T = A,B,C,D,...
Is there a way that I can pass the contents of the tuple to the functionwithout explicitly indexing the elements? Something like:
myfunc(magic(T))
where magic() expands the tuple to its multiple elements. I'vetried various for loop constructs, but everything I can think of returns alist, which doesn't work because it's viewed as one parameter.
thanks,
Ben 1 7596
On Sep 6, 11:02 pm, Ben Warren <bwar...@qstreams.comwrote:
Hello,
Let's say I have a function with a variable number of arguments (please ignore syntax errors):
def myfunc(a,b,c,d,...):
and I have a tuple whose contents I want to pass to the function. The number of elements in the tuple will not always be the same.
T = A,B,C,D,...
Is there a way that I can pass the contents of the tuple to the function without explicitly indexing the elements?
Yes:
myfunc(*T)
More details at http://docs.python.org/tut/node6.htm...00000000000000
HTH,
George This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kay Schluehr |
last post by:
Hi all,
thanks for Your attention !
I think my proposal was more in mind of Rons modified exec than
Pythons lambda.
When George proposed his unpacking behavoir for list-comps as a pack of...
|
by: lugal |
last post by:
This might be more appropriate here. I'm new to C++, coming from a
background in another languages that allowed a similar solution to work
(Python). I wrote the following code in C++ based on the...
|
by: imdognuts |
last post by:
Hi,
I want to pass something like this to a C function via the Python C
API.
mytuple = (("string_one", 1.2, 1.3), ("string_two", 1.4, 1.5), ......,
......, )
This tuple is dynamic in size, it...
|
by: 63q2o4i02 |
last post by:
Hi,
I'm writing a hand-written recursive decent parser for SPICE syntax
parsing. In one case I have one function that handles a bunch of
similar cases (you pass the name and the number of...
|
by: vml |
last post by:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
class Fop:
_public_methods_ =
def SqVal(self,*val):
#vol=(val,val)...
|
by: beginner |
last post by:
Hi,
I am wondering how do I 'flatten' a list or a tuple? For example, I'd
like to transform or ] to .
Another question is how do I pass a tuple or list of all the
aurgements of a function to...
|
by: montyphyton |
last post by:
Recently, I got into a debate on programming.reddit.com about
what should happen in the following case:
Currently, Python raises an error *and* changes the first element of
the tuple. Now,...
|
by: Scott |
last post by:
I'm trying to write a function that accepts a variable number of
arguments and passes those arguments to another function. Here is an
example:
def foo(*args):
print "I'm going to call bar with...
|
by: Martin Geisler |
last post by:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkjlQNwACgkQ6nfwy35F3Tj8ywCgox+XdmeDTAKdN9Q8KZAvfNe4
0/4AmwZGClr8zmonPAFnFsAOtHn4JhfY
=hTwE
-----END PGP...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |