Howto pass Array/Hash into Function

W

Wijaya Edward

Hi,

How can I pass Array, Hash, and a plain variable
in to a function at the same time.

I come from Perl. Where as you probably know
it is done like this:

sub myfunc {

my ($plain_var, $hash_ref,$arref) = @_;
# Do sth with those variables

return;
}

I wonder how can that be done in Python.

Regards,
Edward WIJAYA
SINGAPORE

------------ Institute For Infocomm Research - Disclaimer -------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you.
--------------------------------------------------------
 
W

Wildemar Wildenburger

MonkeeSage said:
def myfunc(plain_var, hash_ref, arref):
# Do sth with those variables
return

At the risk of being a jerk (sorry, I'm really just curious):
Why isn't that obvious?

wildemar (sorry)
 
M

MonkeeSage

Wildemar said:
At the risk of being a jerk (sorry, I'm really just curious):
Why isn't that obvious?

wildemar (sorry)

I wondered that too and wasn't even going to answer, but then I thought
mabye the question was meant to be more general, like "what is the
syntax for passing objects to functions in python?"

Regards,
Jordan
 
S

Steve Holden

MonkeeSage said:
I wondered that too and wasn't even going to answer, but then I thought
mabye the question was meant to be more general, like "what is the
syntax for passing objects to functions in python?"
It wouldn't be obvious to someone who learned Perl as their first
programming language because Perl chose to ignore the otherwise almost
universal convention that formal parameters determine the arguments that
a function or procedure can be calles with.

regards
Steve
 
W

Wijaya Edward

Thanks for your understanding Steve.

Furthermore, my related concern
is how does Python actually deal with 'reference' in Perl.
But now, it is clear to me now that Python simply
treats them as object.

Regards,
Edward WIJAYA
SINGAPORE

________________________________

From: [email protected] on behalf of Steve Holden
Sent: Tue 10/3/2006 8:08 PM
To: (e-mail address removed)
Subject: Re: Howto pass Array/Hash into Function




It wouldn't be obvious to someone who learned Perl as their first
programming language because Perl chose to ignore the otherwise almost
universal convention that formal parameters determine the arguments that
a function or procedure can be calles with.

regards
Steve




------------ Institute For Infocomm Research - Disclaimer -------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you.
--------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top