another newbie question: why should you use "*args" ?

stef s.mientki at id.umcn.nl
Wed Jan 31 17:20:31 CET 2007


>> I would love that,
>> but please tell me how (I need an integer counter for something else too):
>>
>> def chunk_plot(*args):
>>     if len(args) == 1:  list = args[0]
>>     else:               list = args
>>  
>>     color = ['g','r','b','y','m']
>>     plot ( list[0], color[0])
>>     hold (True)
>>     for i in range  (  1,  len(list)  ):
>>          plot  (  list[i],  color[i]  )
>>     
>
> No need for the counter here.
>
> for args in zip(list[1:], color[1:]):
>     plot(*args)
>
>   
that looks nice, thanks!
All the other people also thanks, "enumerate" looks also better than 
range(len(  nice !
> Ciao,
> 	Marc 'BlackJack' Rintsch
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070131/b05d902b/attachment.html>


More information about the Python-list mailing list