Re: Finding good documentation for gpiod

2023-09-03 Thread Barry via Python-list
E > On 3 Sep 2023, at 22:49, Chris Green via Python-list > wrote: > > Mostly I am managing to get things to work as I want but better > documentation of gpiod would be a great help. Ask the author? https://github.com/aswild/python-gpiod Maybe read the source code for hints? Barry -- https:/

Re: Forward References

2023-09-03 Thread MRAB via Python-list
On 2023-09-03 21:43, Jonathan Gossage via Python-list wrote: I am attempting to use forward references in my program and I am failing. This also does not work with the older way of putting the name of a class as a string. Here is some sample code: from __future__ import annotations from datacla

Re: iterations destroy reversed() results

2023-09-03 Thread Chris Angelico via Python-list
On Mon, 4 Sept 2023 at 07:44, Pierre Fortin via Python-list wrote: > > Hi, > > reversed() results are fine until iterated over, after which the > results are no longer available. This was discovered after using > something like this: > > rev = reversed( sorted( list ) ) > sr = sum( 1 for _ in rev

Re: Passing info to function used in re.sub

2023-09-03 Thread Thomas Passin via Python-list
On 9/3/2023 12:10 PM, Jan Erik Moström via Python-list wrote: I'm looking for some advice for how to write this in a clean way I want to replace some text using a regex-pattern, but before creating replacement text I need to some file checking/copying etc. My code right now look something like

Re: iterations destroy reversed() results

2023-09-03 Thread Thomas Passin via Python-list
On 9/1/2023 12:15 PM, Pierre Fortin via Python-list wrote: Hi, reversed() results are fine until iterated over, after which the results are no longer available. This was discovered after using something like this: rev = reversed( sorted( list ) ) sr = sum( 1 for _ in rev ) # rev is now destroye

Re: iterations destroy reversed() results

2023-09-03 Thread Dom Grigonis via Python-list
It is by design. `sorted` returns a list, while `reversed` returns an iterator. Iterators are exhaust-able, and not reusable. So be mindful of this and if you are going to "re-use” the sequence returned by iterator, convert it to list first. Have a look at `itertools` library, which contains a

Finding good documentation for gpiod

2023-09-03 Thread Chris Green via Python-list
I am using the gpiod package for manipulating GPIO inputs/outputs on a Beaglebone Black SBC (like a Raspberry Pi but with more flexible I/O). Mostly I am managing to get things to work as I want but better documentation of gpiod would be a great help. For example, when one has found an I/O pin (a

iterations destroy reversed() results

2023-09-03 Thread Pierre Fortin via Python-list
Hi, reversed() results are fine until iterated over, after which the results are no longer available. This was discovered after using something like this: rev = reversed( sorted( list ) ) sr = sum( 1 for _ in rev ) # rev is now destroyed So reversed() results can only be iterated once unlike so

Re: Why do I always get an exception raised in this __init__()?

2023-09-03 Thread Chris Green via Python-list
Alan Gauld wrote: > On 31/08/2023 22:15, Chris Green via Python-list wrote: > > > class Gpiopin: > > > > def __init__(self, pin): > > # > > # > > # scan through the GPIO chips to find the line/pin we want > > # > > for

Forward References

2023-09-03 Thread Jonathan Gossage via Python-list
I am attempting to use forward references in my program and I am failing. This also does not work with the older way of putting the name of a class as a string. Here is some sample code: from __future__ import annotations from dataclasses import dataclass from typing import TypeAlias ColorDef:

Re: Passing info to function used in re.sub

2023-09-03 Thread Jan Erik Moström via Python-list
On 3 Sep 2023, at 19:13, MRAB via Python-list wrote: > You could use pass an anonymous function (a lambda) to re.sub: Of course !! Thanks. = jem -- https://mail.python.org/mailman/listinfo/python-list

Re: Passing info to function used in re.sub

2023-09-03 Thread MRAB via Python-list
On 2023-09-03 17:10, Jan Erik Moström via Python-list wrote: I'm looking for some advice for how to write this in a clean way I want to replace some text using a regex-pattern, but before creating replacement text I need to some file checking/copying etc. My code right now look something like

Passing info to function used in re.sub

2023-09-03 Thread Jan Erik Moström via Python-list
I'm looking for some advice for how to write this in a clean way I want to replace some text using a regex-pattern, but before creating replacement text I need to some file checking/copying etc. My code right now look something like this: def fix_stuff(m): # Do various things that invol