Re: [PATCH 4/4] pylibfdt: add FdtRo.getprop_or_none()

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



Hi Simon,

On Dienstag, 28. Dezember 2021 09:34:57 CET Simon Glass wrote:
> Hi Luca,
> 
> On Sat, 25 Dec 2021 at 06:26, Luca Weiss <luca@xxxxxxxxx> wrote:
> > Add a new method that doesn't throw an exception when a property isn't
> > found but returns None instead.
> > 
> > Also add a test for the new method.
> 
> You can use
> 
> getprop(node, prop, quiet=QUIET_NOTFOUND)
> 

This returns -1 when not found which I found quite un-pythonic (not that 
pylibfdt is currently super pythonic ;) ).
Having None returned if not found is much nicer to use and much more clear to 
use

    if foobar is None:

 instead of having to use

    if foobar == -QUIET_NOTFOUND:


Are there any changes I can do for you to reconsider your position on this 
patch?

Regards
Luca

> > Signed-off-by: Luca Weiss <luca@xxxxxxxxx>
> > ---
> > 
> >  pylibfdt/libfdt.i       | 10 ++++++++++
> >  tests/pylibfdt_tests.py |  2 ++
> >  2 files changed, 12 insertions(+)
> 
> Regards,
> Simon







[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux