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

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

 



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.

> Is that clearer?

-- 
With Best Regards,
Andy Shevchenko





[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