On Sat, 12 Jul 2008 16:32:25 -0400, Terry Reedy wrote:
> Steven D'Aprano wrote:
>> On Thu, 10 Jul 2008 14:09:16 -0400, Terry Reedy wrote:
>>
g = lambda x:validate(x)
>>> This is doubly diseased.
>>>
>>> First, never write a 'name = lambda...' statement since it is
>>> equivalent to a def
Steven D'Aprano wrote:
On Thu, 10 Jul 2008 14:09:16 -0400, Terry Reedy wrote:
g = lambda x:validate(x)
This is doubly diseased.
First, never write a 'name = lambda...' statement since it is equivalent
to a def statement except that the resulting function object lacks a
proper .funcname attr
On Thu, 10 Jul 2008 14:09:16 -0400, Terry Reedy wrote:
>> g = lambda x:validate(x)
>
> This is doubly diseased.
>
> First, never write a 'name = lambda...' statement since it is equivalent
> to a def statement except that the resulting function object lacks a
> proper .funcname attribute.
U
In article
<[EMAIL PROTECTED]>,
ssecorp <[EMAIL PROTECTED]> wrote:
> >>> def mod(x,y):
> return x.append(y)
>
> >>> mod([1,2],3)
> >>> k=[1,2,3]
> >>> k
> [1, 2, 3]
> >>> l = mod(k,4)
> >>> l
> >>> k
> [1, 2, 3, 4]
> >>> l
> >>> k==l
> False
> >>> mod(k,5)
> >>> k
> [1, 2, 3, 4, 5]
> >>>
In article <[EMAIL PROTECTED]>,
Terry Reedy <[EMAIL PROTECTED]> wrote:
> David C. Ullrich wrote:
> > In article
> > <[EMAIL PROTECTED]>,
> > ssecorp <[EMAIL PROTECTED]> wrote:
> >
> >> I am never redefining the or reassigning the list when using validate
> >> but since it spits the modified li
On Jul 10, 9:46 pm, ssecorp <[EMAIL PROTECTED]> wrote:
> >>> def mod(x,y):
>
> return x.append(y)
>
append adds y to list x and returns None, which is then returned by
mod.
>
>
> >>> mod([1,2],3)
> >>> k=[1,2,3]
> >>> k
> [1, 2, 3]
> >>> l = mod(k,4)
4 has been appended to list k and mod h
>>> def mod(x,y):
return x.append(y)
>>> mod([1,2],3)
>>> k=[1,2,3]
>>> k
[1, 2, 3]
>>> l = mod(k,4)
>>> l
>>> k
[1, 2, 3, 4]
>>> l
>>> k==l
False
>>> mod(k,5)
>>> k
[1, 2, 3, 4, 5]
>>> mod(l,4)
Traceback (most recent call last):
File "", line 1, in
mod(l,4)
File "", line 2, in m
ty very good answer. i know i shouldn't use lambda like that, i never
do i was just playing around there and then this happened which i
thought was weird.
On Jul 10, 8:09 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> David C. Ullrich wrote:
> > In article
> > <[EMAIL PROTECTED]>,
> > ssecorp
David C. Ullrich wrote:
In article
<[EMAIL PROTECTED]>,
ssecorp <[EMAIL PROTECTED]> wrote:
I am never redefining the or reassigning the list when using validate
but since it spits the modified list back out that somehow means that
the modified list is part of the environment and not the old
In article
<[EMAIL PROTECTED]>,
ssecorp <[EMAIL PROTECTED]> wrote:
> I am never redefining the or reassigning the list when using validate
> but since it spits the modified list back out that somehow means that
> the modified list is part of the environment and not the old one.
> i thought what
Python doesn't use value semantics for variables but reference semantics:
a = [1]
b = a
In many languages, you'd now have 2 lists. In Python you still have one list,
and both a and b refer to it.
Now if you modify the data (the list), both variables will change
a.append(2) # in-place modificat
11 matches
Mail list logo