On Wed, Oct 26, 2022 at 02:34:23PM +0200, Bartosz Golaszewski wrote: > This adds the regular set of example programs implemented using libgpiod > python bindings. ... > +if __name__ == "__main__": > + for chip in gpio_chips(): > + info = chip.get_info() > + print("{} [{}] ({} lines)".format(info.name, info.label, info.num_lines)) In all of them I would prefer to see the main() explicitly, like def main(): ... if __name__ == "__main__": main() (In this case the module can be imported by another one and main be reused) Also have you considered use of SystemExit() wrapper? ... > + sys.exit(0) > + > + sys.exit(1) Is it in the original C code?! I would expect that no chips -- no error. ... > +if __name__ == "__main__": > + if len(sys.argv) < 3: > + raise TypeError("usage: gpioget.py <gpiochip> <offset1> <offset2> ...") SystemExit(main(sys.argv)) ? > + path = sys.argv[1] > + lines = [int(line) if line.isdigit() else line for line in sys.argv[2:]] > + > + request = gpiod.request_lines( > + path, > + consumer="gpioget.py", > + config={tuple(lines): gpiod.LineSettings(direction=Direction.INPUT)}, > + ) > + > + vals = request.get_values() > + > + for val in vals: > + print("{} ".format(val.value), end="") > + print() Without any conditional it will print an empty line, was it originally in the C variant? -- With Best Regards, Andy Shevchenko