Marc 'BlackJack' Rintsch a écrit :
> On Tue, 23 Oct 2007 11:48:08 +0200, Loic Mahe wrote:
>
>> even shorter:
>>
>> def funcA(tarray):
>> s = min(len(tarray), 3)
>> return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
>
> Why the list comprehension!?
>
> Ciao,
> Marc 'Blackjack'
On Tue, 23 Oct 2007 11:48:08 +0200, Loic Mahe wrote:
> even shorter:
>
> def funcA(tarray):
> s = min(len(tarray), 3)
> return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
Why the list comprehension!?
Ciao,
Marc 'Blackjack' Rintsch
--
http://mail.python.org/mailman/listinf
even shorter:
def funcA(tarray):
s = min(len(tarray), 3)
return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
--
http://mail.python.org/mailman/listinfo/python-list
"Yinghe Chen" <[EMAIL PROTECTED]> writes:
> def funcA(tarray):
>a = [2,3,4]
> if len(tarray) >=3:
> return a[0],a[1], a[2]
> elif len(tarray) == 2:
> return a[0],a[1], funcB(1)[0]
> elif len(tarray) == 1:
>return a[0], funcB(2)[0]
On Tue, 23 Oct 2007 16:28:37 +0800, Yinghe Chen wrote:
> Hello gurus,
>
> I have a question, a function like below, it is implemented by me, :)
>
> def funcA(tarray):
>a = [2,3,4]
> if len(tarray) >=3:
> return a[0],a[1], a[2]
> elif len(tarray) == 2:
>
Hello gurus,
I have a question, a function like below, it is implemented by me, :)
def funcA(tarray):
a = [2,3,4]
if len(tarray) >=3:
return a[0],a[1], a[2]
elif len(tarray) == 2:
return a[0],a[1], funcB(1)[0]
elif len(tarray) == 1: