Re: Howto pass Array/Hash into Function

2006-10-03 Thread MonkeeSage
Wijaya Edward wrote:
 I wonder how can that be done in Python.

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

Regards,
Jordan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto pass Array/Hash into Function

2006-10-03 Thread Wildemar Wildenburger
MonkeeSage wrote:
 Wijaya Edward wrote:
 I wonder how can that be done in Python.
 
 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)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto pass Array/Hash into Function

2006-10-03 Thread MonkeeSage
Wildemar Wildenburger wrote:
 MonkeeSage wrote:
  Wijaya Edward wrote:
  I wonder how can that be done in Python.
 
  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)

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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto pass Array/Hash into Function

2006-10-03 Thread Gabriel G

At Tuesday 3/10/2006 06:05, Wijaya Edward wrote:


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;
}


In Python your functions have formal arguments:

def myfunc(plain_var, some_dict, some_list):
# ...
return

You also have positional and keyword arguments, and default values. 
Read the Python tutorial http://www.python.org/doc/current/tut/tut.html




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Howto pass Array/Hash into Function

2006-10-03 Thread Steve Holden
MonkeeSage wrote:
 Wildemar Wildenburger wrote:
 
MonkeeSage wrote:

Wijaya Edward wrote:

I wonder how can that be done in Python.

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)
 
 
 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
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Howto pass Array/Hash into Function

2006-10-03 Thread 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: python-list@python.org
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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto pass Array/Hash into Function

2006-10-03 Thread Fredrik Lundh
Wijaya Edward wrote:

 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.

sounds like you really need to reset your brain:

 http://effbot.org/zone/python-objects.htm

/F

-- 
http://mail.python.org/mailman/listinfo/python-list