473,321 Members | 1,669 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,321 software developers and data experts.

passing *args "recursively"


Hi,

This must be very basic, but how'd you pass the same *args several
levels deep?
def func2(*args)

print args # ((1, 2, 3),)
# i want this to output (1, 2, 3) as func1!
# there must be some better way than args[0]?

def func1(*args):

print args # (1, 2, 3)
func2(args)

func1(1,2,3)

Thanks!

Guillermo
Jun 27 '08 #1
5 1421
On Mon, May 12, 2008 at 12:19 PM, Guillermo
<gu**************@googlemail.comwrote:
def func1(*args):
print args # (1, 2, 3)
func2(args)
change this line to:
func2(*args)

--
Jerry
Jun 27 '08 #2
On May 12, 9:19 am, Guillermo <guillermo.lis...@googlemail.comwrote:
Hi,

This must be very basic, but how'd you pass the same *args several
levels deep?

def func2(*args)

print args # ((1, 2, 3),)
# i want this to output (1, 2, 3) as func1!
# there must be some better way than args[0]?

def func1(*args):

print args # (1, 2, 3)
func2(args)

func1(1,2,3)

Thanks!

Guillermo
def func1(*args):
print args
func2(*args) # don't forget the '*'

Matt
Jun 27 '08 #3
Guillermo wrote:
This must be very basic, but how'd you pass the same *args several
levels deep?

def func2(*args)
print args # ((1, 2, 3),)
# i want this to output (1, 2, 3) as func1!
# there must be some better way than args[0]?

def func1(*args):
print args # (1, 2, 3)
func2(args)

func1(1,2,3)
func2(*args)

Thats all. See
http://docs.python.org/tut/node6.htm...00000000000000

/MiO
Jun 27 '08 #4
Guillermo wrote:
>This must be very basic, but how'd you pass the same *args several
levels deep?

def func2(*args)
print args # ((1, 2, 3),)
# i want this to output (1, 2, 3) as func1!
# there must be some better way than args[0]?

def func1(*args):
print args # (1, 2, 3)
func2(args)

func1(1,2,3)
Me, myself and I wrote:
func2(*args)

Thats all. See
http://docs.python.org/tut/node6.htm...00000000000000
That was a bit unclear. You should use func2(*args) when you call the
function.

/MiO
Jun 27 '08 #5
In article <ee**********************************@e53g2000hsa. googlegroups.com>,
Guillermo <gu**************@googlemail.comwrote:
>
Hi,

This must be very basic, but how'd you pass the same *args several
levels deep?
def func2(*args)

print args # ((1, 2, 3),)
# i want this to output (1, 2, 3) as func1!
# there must be some better way than args[0]?

def func1(*args):

print args # (1, 2, 3)
func2(args)
func2(*args) # <<<<<<======
>
func1(1,2,3)
Gary Duzan
Motorola H&NM
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville...
53
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions...
17
by: Nollie | last post by:
Say you have a struct: struct MYSTRUCT { int x; int y; int w; int h; };
10
by: paulw | last post by:
Hi Please give problems that "HAS TO" to use recursion (recursive calls to itself.) Preferrably real world examples, not knights tour. I'm thinking about eliminating the use of stack... ...
4
by: bennett | last post by:
How can I do a loop from 1 to 5, where on line 1 I print 1 space followed by a button, on line 2 I print 2 spaces followed by a button, on line 3 I print 3 spaces followed by a button, etc.? I...
11
by: comp.lang.php | last post by:
function blah($item) { if (!isset($baseDir)) { static $baseDir = ''; $baseDir = $item; print_r("baseDir = $baseDir\n"); } $dirID = opendir($item); while (($fyl = readdir($dirID)) !== false)...
5
by: Frederick Gotham | last post by:
If we have a simple class such as follows: #include <string> struct MyStruct { std::string member; MyStruct(unsigned const i) {
11
by: Stef Mientki | last post by:
hello, Is there some handy/ nice manner to view the properties of some variable ? As a newbie, I often want to see want all the properties of a var, and also some corner values (large arrays)...
7
by: Rahul | last post by:
Hi Everyone, I have the following code, void f(int &) { printf("in f...\n"); } #ifdef __cplusplus
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.