"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:
>>
>>>
<[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
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
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
>> 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
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
"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
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