another newbie question: why should you use "*args" ?
stef
s.mientki at id.umcn.nl
Wed Jan 31 10:44:11 EST 2007
Eugene Antimirov wrote:
> stef wrote:
>
>> # method 2
>> def chunk_plot(self, list):
>> for i in range ( len(list) ):
>> .... do something
>
>
> 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] )
cheers,
Stef
More information about the Python-list
mailing list