Enumming

magnus_kessler at my-deja.com magnus_kessler at my-deja.com
Tue Aug 22 04:43:22 EDT 2000


In article <jwbnews-
399BFD.16352321082000 at news.olympus.net>,
  "John W. Baxter" <jwbnews at scandaroon.com> wrote:
> Let me try that again (for some, my cancel will
have worked, soon
> enough, and you'll think "*again?".  Starting
with Python 1.6, we can say
> myList.append( (functionA(), funcationB(),
functionC(),
> functionD(),functionD()) )
>
> But unfortunately that's not friendly now: it
appends the tuple as one
> item:
>
> >>> a = []
> >>> a.append((1, 2, 3))
> >>> a
> [(1, 2, 3)]
>
> To work with 1.5.2 and 1.6, the loop would need
to be something like
>
>      for i in range( 10 ):
>         myList.append( functionA() )
>         myList.append( functionB() )
>         myList.append( functionC() )
>         myList.append( functionD() )
>         myList.append( functionE() )
>
> Perhaps with a comment suggesting the single
append for some future time
> when 1.5.2 and earlier versions do no matter.
>
> --
> John W. Baxter   Port Ludlow, WA USA
jwbnews at scandaroon.com
>

You might want to consider using the extend()
function instead of append()

>>> a = []
>>> a.extend([1, 2, 3])
>>> a
[1, 2, 3]

Regards

Magnus



Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list