another newbie question: why should you use "*args" ?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Jan 31 11:01:59 EST 2007
In <4b4a3$45c0b94c$83aef404$20934 at news1.tudelft.nl>, stef wrote:
> Eugene Antimirov wrote:
>
>> And one note more. Just to be more pythonic you shouldn't use form
>> range(len(blabla)). Instead use:
>>
>> for i in list:
>> ....blabla...
>>
>>
> 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)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list