Re: [PATCH] python: simplify complicated conditional assignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Wed, 21 Aug 2013 10:24:16 -0600,
Eric Blake wrote:
> 
> On 08/21/2013 08:05 AM, Claudio Bley wrote:
> > 
> > Signed-off-by: Claudio Bley <cbley@xxxxxxxxxx>
> > ---
> > Just noticed this while reading the generated .py files.
> > 
> > Might save a few cycles eventually...
> > 
> >  python/generator.py |    3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> ACK.

Thanks.

But, I was still thinking about a possible case where doing the
assignment in this way was necessary or useful.

In the case if someone actually overwrites the __ne__ operator
of a class in some strange way:

def __ne__(self, other):
  if other is None:
    return False
  else:
    return NotImplemented

(and __eq__ likewise), such that the instance would compare equal to
None, the semantic of the codes would differ.

IMO, we don't need to care if someone chooses to implement such
awkward equality rules. In the end, (s)he could directly pass None as
an argument if None is what is inteded. So, I'm going to push this if
nobody objects in the next few hours.

Furthermore, one should not compare to None using the equality
operators anyways, as recommended by PEP 8. Next patch coming up...

/ Claudio
-- 
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]