question about functions

Donn Cave donn at drizzle.com
Fri Apr 15 01:09:55 EDT 2005


Quoth "chris patton" <chrispatton at gmail.com>:
| Hi everyone.
|
| I have a question about passing arguments to python functions. Is there
| any way to make this job act like Perl?
|
| sub my_funk {
|
| print "the first argument: $_[0]\n";
| print "the second argument: $_[1]\n";  }
|
| In other words, can I call the arguments from a list?


	def my_funk(*a):
		print 'first', a[0]
		print 'second', a[1]

	my_funk('one', 'two')

You can mix this with normal argument usage, and there is a
similar way to pass parameters to a function from a tuple.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list