[Freeipa-devel] [PATCH] 142 Improve default user/group object class validation
Martin Kosek
mkosek at redhat.com
Tue Oct 11 11:21:29 UTC 2011
On Tue, 2011-10-11 at 13:57 +0300, Alexander Bokovoy wrote:
> On Tue, 11 Oct 2011, Martin Kosek wrote:
> > This was done on purpose. When you combine 2 lists in Python using +
> > operator, a new list is created without modifying the old one. Check the
> > following example:
> >
> > >>> a = [1,2,3]
> > >>> b = [4]
> > >>> c = a+b
> > >>> print c
> > [1, 2, 3, 4]
> > >>> print a
> > [1, 2, 3]
> > >>> print b
> > [4]
> > >>> c.append(5)
> > >>> print c
> > [1, 2, 3, 4, 5]
> > >>> print a
> > [1, 2, 3]
> > >>> print b
> > [4]
> Sorry, but this is not our case:
> >>> a = [1,2,3]
> >>> b = a
> >>> b += [4]
> >>> print a
> [1, 2, 3, 4]
> >>> print b
> [1, 2, 3, 4]
>
You are right. This is an important Python lesson for me. c=c+a is NOT
equal to c+=a as it is in C. Behold:
>>> a=[1,2,3]
>>> b=a
>>> b = b + [4]
>>> a
[1, 2, 3]
>>> b
[1, 2, 3, 4]
>>>
>>>
>>> a=[1,2,3]
>>> b=a
>>> b+= [4]
>>> a
[1, 2, 3, 4]
>>> b
[1, 2, 3, 4]
Updated patch attached.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-mkosek-142-3-improve-default-user-group-object-class-validation.patch
Type: text/x-patch
Size: 3818 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20111011/befce003/attachment.bin>
More information about the Freeipa-devel
mailing list