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

2007-01-31 Thread stef
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

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

2007-01-31 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 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 someth

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

2007-01-31 Thread Jeffrey Froman
stef 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): for index, item in enumerate(args):

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

2007-01-31 Thread stef
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: > b

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

2007-01-31 Thread Eugene Antimirov
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... -- Sincerely, Eugene Antimirov

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

2007-01-31 Thread stef
It's bad practice to use built-ins like 'list' as a regular variable name. ok, but it was just an example (in practice, I always use very long names ;-) # calling method 1: execute (S[0], S[4] ) # calling method 2: execute ( ( S[0], S[4] ) ) Let's take a look at those side-by-sid

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

2007-01-31 Thread Dustan
On Jan 31, 5:41 am, stef <[EMAIL PROTECTED]> wrote: > why should I use *args, > as in my ignorance, > making use of a list (or tupple) works just as well, > and is more flexible in it's calling. Others have mentioned the instances in which it's actually useful - for catch-all arguments. But you al

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

2007-01-31 Thread Bruno Desthuilliers
stef a écrit : > > why should I use *args, > as in my ignorance, > making use of a list (or tupple) works just as well, > and is more flexible in it's calling. Err... How so ? > So the simple conclusion might be: never use "*args", > or am I overlooking something ? Try writing generic higher or

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

2007-01-31 Thread Diez B. Roggisch
stef wrote: > > why should I use *args, > as in my ignorance, > making use of a list (or tupple) works just as well, > and is more flexible in it's calling. > So the simple conclusion might be: never use "*args", > or am I overlooking something ? Yup. For example decorators, that wrap functions.

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

2007-01-31 Thread stef
why should I use *args, as in my ignorance, making use of a list (or tupple) works just as well, and is more flexible in it's calling. So the simple conclusion might be: never use "*args", or am I overlooking something ? # method 1 def execute (self, *args): for i in range ( len(args)