MackS wrote:
(snip)
>>What's preventing the use of list comprehensions?
>>
>>new_list = [x+1 for x in old_list]
>
> Suppose I want to do anything as trivial as modify the values of the
> list members _and_ print their new values.
Then it's a sure design smell IMHO. Don't mix presentation wi
"MackS" <[EMAIL PROTECTED]> writes:
> Thank you for your reply.
A pleasure to help.
> > What's preventing the use of list comprehensions?
> >
> > new_list = [x+1 for x in old_list]
>
> Suppose I want to do anything as trivial as modify the values of the
> list members _and_ print their new
Thank you for your reply.
> > 1) Is what I wrote above (minimally) correct?
>
> Correct for what? You can tell if it's *syntactically* correct by
> simply running it.
>
> As for any other "correct", define that. Does it do what you want it
> to do?
I was referring to my attempted explanation, no
"MackS" <[EMAIL PROTECTED]> writes:
[MackS, please don't top-post.]
> Suppose I want to do modify all arguments which are passed to a
> function. Do I need to use a list comprehension such as
>
> def f(arg1,arg2,arg3):
>
> arg1,arg2,arg3 = [i+1 for i in (arg1,arg2,arg3)]
> ...
>
> Th
"MackS" <[EMAIL PROTECTED]> writes:
> >>> l = [1,2]
> >>> for i in l:
> ... i = i + 1
> ...
> >>> l
> [1, 2]
>
> I understand (I think!) that this is due to the fact that in Python
> what looks like "assignment" really is binding a name to an
> object. The result is that inside the loop I am
Sorry, my previous post probably was not very good at explaining _why_
I want to do this.
Suppose I want to do modify all arguments which are passed to a
function. Do I need to use a list comprehension such as
def f(arg1,arg2,arg3):
arg1,arg2,arg3 = [i+1 for i in (arg1,arg2,arg3)]
...
Hello everyone
Consider the following
>>> l = [1,2]
>>> for i in l:
... i = i + 1
...
>>> l
[1, 2]
I understand (I think!) that this is due to the fact that in Python
what looks like "assignment" really is binding a name to an object. The
result is that inside the loop I am creating an objec