Re: function call - default value & collecting arguments

2008-04-03 Thread Primoz Skale
"OKB (not okblacke)" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Primoz Skale wrote: > >> OK, everything allright till so fair. But! :) Now define third >> function as: >> >> def f(*a): >>print a[0] >> >> In this case, function only prints first argument in the tuple: >> >>>

Re: function call - default value & collecting arguments

2008-04-03 Thread Primoz Skale
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2 avr, 22:32, "Primoz Skale" <[EMAIL PROTECTED]> wrote: >> >> I also understand (fairly) how to collect arguments. For example, >> >> let's >> >> define another function: >> >> >> def f(*a): >> >>print a >> >> > This means that

Re: function call - default value & collecting arguments

2008-04-02 Thread OKB (not okblacke)
Primoz Skale wrote: > OK, everything allright till so fair. But! :) Now define third > function as: > > def f(*a): >print a[0] > > In this case, function only prints first argument in the tuple: > >>>f(1,2,3) > 1 >>>f(3) > 3 >>>f()#no arguments passed > Traceback (most recent call last

Re: function call - default value & collecting arguments

2008-04-02 Thread [EMAIL PROTECTED]
On 2 avr, 22:32, "Primoz Skale" <[EMAIL PROTECTED]> wrote: > >> I also understand (fairly) how to collect arguments. For example, let's > >> define another function: > > >> def f(*a): > >>print a > > > This means that f takes any number of optional positional arguments. > > If nothing is passed

Re: function call - default value & collecting arguments

2008-04-02 Thread Primoz Skale
>> I also understand (fairly) how to collect arguments. For example, let's >> define another function: >> >> def f(*a): >>print a > > This means that f takes any number of optional positional arguments. > If nothing is passed, within f, 'a' will be an empty tuple. Note that > this is *not* the

Re: function call - default value & collecting arguments

2008-04-02 Thread [EMAIL PROTECTED]
On 2 avr, 21:03, "Primoz Skale" <[EMAIL PROTECTED]> wrote: > Hello! > > I am fairly new to Python, so I apologise if this is a 'newbie' question. > > First define a simple function: > > def f(a=0): > print a > > >> f(1) > 1 > >>f() > > 0 > > Argument a in function f() is set at default value of

Re: function call - default value & collecting arguments

2008-04-02 Thread Terry Reedy
"Primoz Skale" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | def f(*a=(0,)): | print a[0] #this should come next, but we get error msg instead, saying | | SyntaxError: invalid syntax | | but it does not work this way. Now my 'newbie' question: Why not? :) Possibly beca

function call - default value & collecting arguments

2008-04-02 Thread Primoz Skale
Hello! I am fairly new to Python, so I apologise if this is a 'newbie' question. First define a simple function: def f(a=0): print a >> f(1) 1 >>f() 0 Argument a in function f() is set at default value of 0, if it is not passed to the function at the function call. I get this! :) I also