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
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
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):
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
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
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
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
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
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.
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)
10 matches
Mail list logo