Re: [libgpiod v2][PATCH v3 2/4] bindings: python: add examples

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

 



On Mon, Oct 17, 2022 at 6:57 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Mon, Oct 17, 2022 at 07:55:41PM +0300, Andy Shevchenko wrote:
> > On Tue, Oct 18, 2022 at 12:20:18AM +0800, Kent Gibson wrote:
> > > On Tue, Oct 18, 2022 at 12:09:10AM +0800, Kent Gibson wrote:
>
> ...
>
> > > Oh, btw, the parser fn version would be something like:
> > >
> > > def parse_value(arg):
> > >      (x,y) = arg.split("=")
> > >      return (x, Value(int(y)))
> >
> > Not a lisp, no need for too many parentheses. Also, we could use splices:
> >
> >       eqidx = arg.index('=')
> >       return arg[:eqidx], Value(int(arg[eqidx + 1:]))
> >
> > or with split()
> >
> >       l, v = arg.split('=')
> >       return l, Value(int(v))
> >
> > > lvs = [ parse_value(arg) for arg in sys.argv[2:]
> >
> > Dunno why you put spaces inside outer [], but okay.
>
> and this actually can be directly put to the dict constructor:
>
>         values = OrderedDict(parse_value(arg) for arg in sys.argv[2:])
>
> This looks short enough and readable.
>

Let's stop bikeshedding, I'll move on to stuff that really matters now. :)

Bartosz



[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