Re: [libgpiod][PATCH 1/2] bindings: python: examples: fix potential glitch in gpioset.py

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

 



On Mon, Jun 12, 2023 at 04:26:46PM +0200, Bartosz Golaszewski wrote:
> On Fri, Jun 9, 2023 at 10:19 PM <andy.shevchenko@xxxxxxxxx> wrote:
> >
> > Fri, Jun 09, 2023 at 11:36:06PM +0800, Kent Gibson kirjoitti:
> > > gpioset.py requests lines without setting their output value, and so
> > > sets them all inactive, and subsequently sets them to their requested
> > > value.  This can result in glitches on lines which were active and
> > > are set active.
> > >
> > > As this is example code, it is also important to demonstrate that the
> > > output value can be set by the request itself.
> > >
> > > Request the lines with the correct output values set in the request
> > > itself.
> >
> > Do we need a comment in the code to specify this?
> >

Andy, I'm not ignoring you - I'm still not getting mail from you, and I
hadn't looked on the list for replies.  Weird.

In answer to your point - yes and no.  The code is not doing anything
unusual, so no.  OTOH it does serve as example code, so a bit of
commentary wouldn't hurt.

> > ...
> >
> > > +    config = dict([(l, settings(v)) for (l, v) in lvs])
> >
> > Aren't [] not needed?
> >

Ok, but now I did get this one:

> Think about it in dynamic:

> In [1]: x= [(1,2),(2,4)]
> In [2]: dict((a,b)for a,b in x)
> Out[2]: {1: 2, 2: 4}

> [] are redundant, so I remembered that correctly 😄

Terrible example - which 2 is which?
1,2,3,4 would've been better.

True - dict() accepts an iterable, so the [] are redundant in thise case.

Cheers,
Kent.



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux