Quoth "chris patton" <[EMAIL PROTECTED]>:
| 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, ca
Am Freitag, 15. April 2005 06:44 schrieb chris patton:
> In other words, can I call the arguments from a list?
Yes.
>>> def testfunc(*args):
... print args[0]
... print args[1]
...
>>> testfunc("this is","a test")
this is
a test
Read up on positional and keyword arguments (the latter are som
Oops, I messed up the indices on the previous post.
Also, maybe you are thinking a bit more perlish:
# start of ascript
def my_funk(*alist):
print "the first argument: %s" % alist[0]
print "the second argument: %s" % alist[1]
my_funk('wuzzup,','g?')
# end of ascript
On Thursday 14 April 20
Just pass a list. E.g.:
# start of ascript
def my_funk(alist):
print "the first argument: %s" % alist[1]
print "the second argument: %s" % alist[2]
mylist = ['wuzzup,','g?']
my_funk(mylist)
# end of ascript
Here is the output you expect:
the first argument: wuzzup,
the second argument:
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?
--
http://mail.python.