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



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
.