Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
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'

Re: How to implement function like this?

2007-10-23 Thread Marc 'BlackJack' Rintsch
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

Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
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

Re: How to implement function like this?

2007-10-23 Thread Paul Rubin
"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]

Re: How to implement function like this?

2007-10-23 Thread Marc 'BlackJack' Rintsch
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: >

How to implement function like this?

2007-10-23 Thread Yinghe Chen
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: