Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Science is what happens when preconception meets verification.


devel / comp.lang.python / Why do I always get an exception raised in this __init__()?

SubjectAuthor
* Why do I always get an exception raised in this __init__()?Chris Green
+- Re: Why do I always get an exception raised in this __init__()?Chris Green
+- Re: Why do I always get an exception raised in this __init__()?Larry Martell
+* Re: Why do I always get an exception raised in this __init__()?Alan Gauld
|`- Re: Why do I always get an exception raised in this __init__()?Chris Green
`- Re: Why do I always get an exception raised in this __init__()?Stefan Ram

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

<ogc7sj-6ilm.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23940&group=comp.lang.python#23940

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!callisto.xs3.de!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Why do I always get an exception raised in this __init__()?
Date: Thu, 31 Aug 2023 22:15:36 +0100
Lines: 69
Message-ID: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net mkDWE27U6LGJDKEZ3ceJyQCFxi1pIttZzPpkERigEPb9lMoGk=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:TyVM5NHNqm04Rwjtalnu0FExmgU= sha256:vBPHyFopmVubhvFjJfQYwHATNDXdiiVfunHted8+H8g=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-79-generic (x86_64))
 by: Chris Green - Thu, 31 Aug 2023 21:15 UTC

I'm obviously doing something very silly here but at the moment I
can't see what.

Here's the code:-

#!/usr/bin/python3
#
#
# GPIO
#
import gpiod
#
#
# Simple wrapper class for gpiod to make set and clearing outputs
easier
#
class Gpiopin:

def __init__(self, pin):
#
#
# scan through the GPIO chips to find the line/pin we want
#
for c in ['gpiochip0', 'gpiochip1', 'gpiochip2', 'gpiochip3']:

chip = gpiod.Chip(c)
for l in range(32):
line = chip.get_line(l)
if pin in line.name():
print("Found: ", line.name())
return
else:
raise ValueError("Can't find pin '" + pin + "'")

def print_name(self):
print (self.line.name())

def set(self):
self.line.set_value(1)

def clear(self):
self.line.set_value(0)

This is by no means the final code, the print() in the __init__() is
just a diagnostic for example. However I really can't understand why I
see the following when I try it:-

>>> import ngp
>>> ngp.Gpiopin("P9_23")
Found: P9_23
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/chris/.cfg/hosts/bbb/bin/ngp.py", line 24, in __init__
return
ValueError: Can't find pin 'P9_23'
>>>

Does a return in __init__() not do what I think it does?

How else could/should I do this?

--
Chris Green
·

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

<e2d7sj-oknm.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23941&group=comp.lang.python#23941

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: Why do I always get an exception raised in this __init__()?
Date: Thu, 31 Aug 2023 22:25:02 +0100
Lines: 11
Message-ID: <e2d7sj-oknm.ln1@esprimo.zbmc.eu>
References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net uHnuk+uQHiZa10MBKlawQw3PYMIFrs8gIG2Ga8aQkDGQOvXk8=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:VJQdX0QudBbJHpgw3st5AKTgWyg= sha256:xUjS9lnanHD+ulq4Pfqn/4D+LdzbwfxCxdRRW10rh+8=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-79-generic (x86_64))
 by: Chris Green - Thu, 31 Aug 2023 21:25 UTC

Chris Green <cl@isbd.net> wrote:

[snip code and question]

Sorry folks, it was a caching problem, I wasn't running the code I
thought I was running! When I made sure I had cleared everything out
and tried again it all worked as I expected.

--
Chris Green
·

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

<mailman.266.1693521335.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23942&group=comp.lang.python#23942

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: larry.ma...@gmail.com (Larry Martell)
Newsgroups: comp.lang.python
Subject: Re: Why do I always get an exception raised in this __init__()?
Date: Thu, 31 Aug 2023 15:34:55 -0700
Lines: 67
Message-ID: <mailman.266.1693521335.23016.python-list@python.org>
References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
<CACwCsY4Mtv4h2j2FFvLBLsikTWXhH_O3-=s9n8juzLRhtVqzMg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 8oPtnK7sJZUMsFRJtzzsLg1qqWUvALc2EaQJaDD6EPAw==
Cancel-Lock: sha1:si27kMvLx5M944mXcPCGKpIXDQQ= sha256:2Ca4nEY9Jh7SB2b4gkjS+rSh0QMHw1kUlT9O7T+CbO8=
Return-Path: <larry.martell@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Mdk5DA8p;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'traceback':
0.04; '(most': 0.05; '31,': 0.05; 'last):': 0.05; '2023': 0.07;
'aug': 0.07; 'subject:Why': 0.07; 'else:': 0.09; 'example.': 0.09;
'obviously': 0.09; 'valueerror:': 0.09; 'import': 0.15; 'found:':
0.16; 'outputs': 0.16; 'subject:()?': 0.16; 'subject:always':
0.16; 'wrapper': 0.16; 'wrote:': 0.16; "can't": 0.17; 'thu,':
0.19; 'to:addr:python-list': 0.20; 'skip:_ 10': 0.22; 'else':
0.27; '>>>': 0.28; 'chris': 0.28; 'this?': 0.29; 'code,': 0.31;
'raise': 0.31; 'think': 0.32; '"",': 0.32; 'python-list': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'following': 0.35; 'final': 0.35; 'from:addr:gmail.com': 0.35;
'change': 0.36; "skip:' 10": 0.37; 'really': 0.37; 'class': 0.37;
'file': 0.38; 'means': 0.38; 'break': 0.39; 'something': 0.40;
'want': 0.40; 'try': 0.40; 'here': 0.62; 'subject:this': 0.67;
'skip:# 10': 0.68; 'subject:get': 0.70; 'moment': 0.81; 'pin':
0.84; 'skip:" 40': 0.84; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1693521332; x=1694126132; darn=python.org;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=60pSoh0vi3WHkp9ks02a0fn4AQv3l57pNZk4nnKowZA=;
b=Mdk5DA8pCw44hyBL7eXjzUxqMsYrpixQ2Zo6PJGmRscstsCiWi/++CkG31MIp6Kml+
ymTGDujcdOF67s6Z5D5GENttnR7L30zBqr8cC6USi+ywHIJsiXhGGMXXF5oVtrmcB8RH
3WstoclhLCfPsq7IK/ZvmSoCBglrN+6sBZfWLjAiT0+C6jjVDeQzLEdcza3e7G4DAbkC
yrPjoez4o12bvQ+Z9ONLwxEdqzbvZttbeNp5JqA0EeJC8cQxUe8GM5x/pxsPwEkG3BbT
bUUDu82P/ZypXuS03PYG7WQSnlFybLygqk5tF1J8HvcAjgxhH0rlo18x0d84ZRlSntXL
WnRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1693521332; x=1694126132;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=60pSoh0vi3WHkp9ks02a0fn4AQv3l57pNZk4nnKowZA=;
b=Qks3hwBW6loq+SH8MIx86JqLIH+xGvygdAWIYLZXUIqS8IUtxjBQDOTtSaKKwpZkel
kJHdy53T9pjZez+WCmM98vsevJhLVUAxwVGuxEUIA2qxwMkGh8CLzft6BdqUDwrOjHLP
qDUCxV3MxPZhYCpWY53FK7LvCfP5SUP/shq7KHifbQ5oZLjtWPfUbRA60cPc3Z0ERBBS
D/vVcfju+oOoNJXBmTs5fNx4N6JswcwqSH2HbGppnbLXUtk4DaWwY3roJ05hpNFP2phh
9WjLj69T6Vq6kvLz65ybbgFopcnwEaYUYSrtkBaV0Y9i3NMizMdYOXydJ2icBRg5Fiz6
t4bQ==
X-Gm-Message-State: AOJu0YyJTZlLt7QgrJZBht3k20DRpZPvbK+qdwgux150YM+O9zDD+A31
QBidzbtpPuzqvAO8Fp94XG8Bd4rIHoefxuFLFFKGkwitDQ==
X-Google-Smtp-Source: AGHT+IEwGT6A9xzmot5xqcuceflQkp8B8QwOlz0JDD24Gb4I4aj3EFe4oCLG7VK/nDh3jyip1bVAh/86EvkVWuj7y18=
X-Received: by 2002:a67:d012:0:b0:44e:9b32:2d84 with SMTP id
r18-20020a67d012000000b0044e9b322d84mr1096950vsi.5.1693521332183; Thu, 31 Aug
2023 15:35:32 -0700 (PDT)
In-Reply-To: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CACwCsY4Mtv4h2j2FFvLBLsikTWXhH_O3-=s9n8juzLRhtVqzMg@mail.gmail.com>
X-Mailman-Original-References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
 by: Larry Martell - Thu, 31 Aug 2023 22:34 UTC

On Thu, Aug 31, 2023 at 3:19 PM Chris Green via Python-list
<python-list@python.org> wrote:
>
> I'm obviously doing something very silly here but at the moment I
> can't see what.
>
> Here's the code:-
>
> #!/usr/bin/python3
> #
> #
> # GPIO
> #
> import gpiod
> #
> #
> # Simple wrapper class for gpiod to make set and clearing outputs
> easier
> #
> class Gpiopin:
>
> def __init__(self, pin):
> #
> #
> # scan through the GPIO chips to find the line/pin we want
> #
> for c in ['gpiochip0', 'gpiochip1', 'gpiochip2', 'gpiochip3']:
>
> chip = gpiod.Chip(c)
> for l in range(32):
> line = chip.get_line(l)
> if pin in line.name():
> print("Found: ", line.name())
> return
> else:
> raise ValueError("Can't find pin '" + pin + "'")
>
> def print_name(self):
> print (self.line.name())
>
> def set(self):
> self.line.set_value(1)
>
> def clear(self):
> self.line.set_value(0)
>
>
> This is by no means the final code, the print() in the __init__() is
> just a diagnostic for example. However I really can't understand why I
> see the following when I try it:-
>
> >>> import ngp
> >>> ngp.Gpiopin("P9_23")
> Found: P9_23
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/chris/.cfg/hosts/bbb/bin/ngp.py", line 24, in __init__
> return
> ValueError: Can't find pin 'P9_23'
> >>>
>
> Does a return in __init__() not do what I think it does?
>
> How else could/should I do this?

Change the return to a break

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

<mailman.267.1693555047.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23943&group=comp.lang.python#23943

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: learn2pr...@gmail.com (Alan Gauld)
Newsgroups: comp.lang.python
Subject: Re: Why do I always get an exception raised in this __init__()?
Date: Fri, 1 Sep 2023 08:57:22 +0100
Lines: 45
Message-ID: <mailman.267.1693555047.23016.python-list@python.org>
References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
<da9bb77b-69e3-f685-e166-3d33f339e26c@yahoo.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de +Cj43tSSAI9nFQaSKsdXOQXuFZu6gJhbozbpwS2v53wQ==
Cancel-Lock: sha1:Wzk9ZrWGdnxNaiIFpzKPP4u3eJE= sha256:BIvmxt9B3OGkLYWz/ehw7UC3jFenekYHoRYfuYJFcL8=
Return-Path: <learn2program@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=cji2mUqr;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'def': 0.04; 'subject:Why':
0.07; 'else:': 0.09; 'anywhere.': 0.16; 'flickr': 0.16;
'from:name:alan gauld': 0.16; 'message-id:@yahoo.co.uk': 0.16;
'photo-blog': 0.16; 'subject:()?': 0.16; 'subject:always': 0.16;
'url-ip:79.170.44.132/32': 0.16; 'url-ip:79.170.44/24': 0.16;
'url-ip:79.170/16': 0.16; 'url-ip:79/8': 0.16; 'url:alan-g': 0.16;
'url:alan_gauld': 0.16; 'url:alangauldphotos': 0.16; 'wrote:':
0.16; 'url:amazon': 0.19; 'to:addr:python-list': 0.20; 'skip:_
10': 0.22; 'to:name:python-list@python.org': 0.24; 'chris': 0.28;
'header:User-Agent:1': 0.30; 'raise': 0.31; 'program': 0.31;
'python-list': 0.32; 'received:192.168.1': 0.32; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'from:addr:gmail.com':
0.35; "skip:' 10": 0.37; 'author': 0.37; 'class': 0.37;
'received:192.168': 0.37; 'use': 0.39; 'alan': 0.40; 'learn':
0.40; 'want': 0.40; 'here.': 0.61; 'follow': 0.62; 'subject:this':
0.67; 'url-ip:18/8': 0.67; 'url:author': 0.69; 'site': 0.70;
'subject:get': 0.70; 'pin': 0.84; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1693555044; x=1694159844; darn=python.org;
h=content-transfer-encoding:in-reply-to:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:from:to:cc:subject:date:message-id:reply-to;
bh=nHmFgN14tm3UGqKBfxlwDCVzHjq81wR9z1sEpuSsMh8=;
b=cji2mUqr3M+qhb5B/kp+J448dzArH0PY9WSDU1qiizo+4HuwlVjBeFdwWHMqJlhu3p
Uc7aIfuhokXJqD57jNDBezkasFWSpieq0l3yoQ+bf3xK5J2MK6Fy3XxgPzC0Xr0b2P58
Qtrug4Pa2n00G4ysS7LAS8vgV15Eqff2w6nxiF0e8k2r9Duof0yUufn3dAJxSAJPke/4
lMY8RQjIInLVqyxZZvvgQ3CJuCemzSMvBhZ9LsLOr5EbJ+tdIWfFSolN74sYWJTbFLeQ
i+5B57F66btLdYTQW09fRSOj+zTSHlLuYtDpG5JZX492qW3/AFYYBmGvft2m5bsX12vK
SxSQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1693555044; x=1694159844;
h=content-transfer-encoding:in-reply-to:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=nHmFgN14tm3UGqKBfxlwDCVzHjq81wR9z1sEpuSsMh8=;
b=IsWm41GggLkFPk4NaMTZugSHprI4fSJ8OILTzeqCoaxTJa60BIU1Ie95KxJsKNrB4u
+X2/+aN7tjGuJqttcyzoO+V55CFgomTbtasTt7jFP0RszDiRU7R77CcohTzjzB27wamR
3VeKGQw3S+EH1RYRCu0MNSkakTeyflduhksSeuuFE6+oifn96LcDABCyHaDEfOEO49Dh
afPTtcK4J2DraWOisIfU0kQteoz7PcDJwPZfAgpZJJ48gEd4LBmIyirjUFRZDDypQeJ3
r2VFbrf7SfobFpkT8uhZxVHJgJLINMzLJn1hv4AJtC+htkFmLnink6T3nw3Ufk8o9d8s
ddOQ==
X-Gm-Message-State: AOJu0YyLbNMQdpAajzA7fCQGjVm58t5xI8zHjceO/Jv8eEWagjgqbva6
muETUmXlc/wimD1y9zvl/vk=
X-Google-Smtp-Source: AGHT+IEkicqapEpbUGaT4fPDPZq+lLfOs2yxH9xFRpozJtTnUP/nqrD3Qu7dX3N1o1inAx4P60IQBQ==
X-Received: by 2002:a1c:4c08:0:b0:3fe:e85b:425d with SMTP id
z8-20020a1c4c08000000b003fee85b425dmr1287203wmf.9.1693555043686;
Fri, 01 Sep 2023 00:57:23 -0700 (PDT)
X-Google-Original-From: Alan Gauld <alan.gauld@yahoo.co.uk>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.12.0
Content-Language: en-GB
In-Reply-To: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <da9bb77b-69e3-f685-e166-3d33f339e26c@yahoo.co.uk>
X-Mailman-Original-References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
 by: Alan Gauld - Fri, 1 Sep 2023 07:57 UTC

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 c in ['gpiochip0', 'gpiochip1', 'gpiochip2', 'gpiochip3']:
>
> chip = gpiod.Chip(c)
> for l in range(32):
> line = chip.get_line(l)
> if pin in line.name():
> print("Found: ", line.name())
> return
> else:
> raise ValueError("Can't find pin '" + pin + "'")

You don't store the line anywhere.
You need to use self.line
self.line = chip.get_line(l)
if pin...

> def print_name(self):
> print (self.line.name())
>
> def set(self):
> self.line.set_value(1)
>
> def clear(self):
> self.line.set_value(0)

As you do here.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

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

<52m8sj-ku7p.ln1@esprimo.zbmc.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23944&group=comp.lang.python#23944

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl...@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: Why do I always get an exception raised in this __init__()?
Date: Fri, 1 Sep 2023 10:04:37 +0100
Lines: 51
Message-ID: <52m8sj-ku7p.ln1@esprimo.zbmc.eu>
References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu> <da9bb77b-69e3-f685-e166-3d33f339e26c@yahoo.co.uk> <mailman.267.1693555047.23016.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net jVm8CpuIgIvtWKHJKVMH5g0eqo3DbY4PhWFNGXVmNzJ7pxFzM=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:5zd0S5URAWYf41CgD6xpNWeEgH0= sha256:f9LUqCCakJR8vi+/9dYI2UQgh1po9JCr7iGMN5eo1S4=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-79-generic (x86_64))
 by: Chris Green - Fri, 1 Sep 2023 09:04 UTC

Alan Gauld <learn2program@gmail.com> 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 c in ['gpiochip0', 'gpiochip1', 'gpiochip2', 'gpiochip3']:
> >
> > chip = gpiod.Chip(c)
> > for l in range(32):
> > line = chip.get_line(l)
> > if pin in line.name():
> > print("Found: ", line.name())
> > return
> > else:
> > raise ValueError("Can't find pin '" + pin + "'")
>
> You don't store the line anywhere.
> You need to use self.line
> self.line = chip.get_line(l)
> if pin...
>
> > def print_name(self):
> > print (self.line.name())
> >
> > def set(self):
> > self.line.set_value(1)
> >
> > def clear(self):
> > self.line.set_value(0)
>
> As you do here.
>
Yes, OK, absolutely. However that wasn't my original rather basic
problem which was, as I said, that I wasn't running the code I was
looking at.

The above was just a quick hack from some even cruder code doing the
same job, trying to develop it into something better and more general.

It's all on a headless Beaglebone Black (bit like a Raspberry Pi) so
I'm doing everything via multiple ssh connections and sometimes this
results in "the left hand not knowing what the right hand is doing"!

--
Chris Green
·

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

<thing-20230901131648@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23946&group=comp.lang.python#23946

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Why do I always get an exception raised in this __init__()?
Date: 1 Sep 2023 12:17:06 GMT
Organization: Stefan Ram
Lines: 7
Expires: 1 Sep 2024 11:59:58 GMT
Message-ID: <thing-20230901131648@ram.dialup.fu-berlin.de>
References: <ogc7sj-6ilm.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de rTz5nJjmiYbx1ljggUKiCw80GBffg71vFX0E0p5HPQ+6im
Cancel-Lock: sha1:gStrrRTKdZy0w5faqv6Gchj34os= sha256:ASczI0wMMyGT/7u0yASauztM5l9ZqDZx4ItJX8cevnA=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Fri, 1 Sep 2023 12:17 UTC

Chris Green <cl@isbd.net> writes:
>I'm obviously doing something very silly here but at the
>moment I can't see what.

not adding debug print statements to see what exactly happens

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor