What sort of exception should a class raise in __init__() when it
can't find an appropriate set of data for the parameter passed in to
the class instantiation?
E.g. I have a database with some names and address in and have a
class Person that gets all the details for a person given their
name.
Several helpful replies, thank you all.
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Chris Green 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
·
--
https://mail.python.org/mailman/listinfo/python
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:
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 wa
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
In the following code is the event polled by the Python process
running the code or is there something cleverer going on such that
Python sees an interrupt when the input goes high (or low)?
import Adafruit_BBIO.GPIO as GPIO
Pin = "P8_8"
GPIO.setup(Pin, GPIO.IN)# set GPIO25 as i
Chris Angelico wrote:
> On Fri, 13 Oct 2023 at 01:48, Chris Green via Python-list
> wrote:
> >
> > In the following code is the event polled by the Python process
> > running the code or is there something cleverer going on such that
> > Python sees an interrupt wh
I am using the python3 smbus module, but it's hard work because of the
lack of documentation. Web searches confirm that the documentation is
somewhat thin!
If you do the obvious this is what you get:-
>>> import smbus
>>> dir (smbus)
['SMBus', '__doc__', '__file__', '__loader__', '__
km wrote:
> Il Sat, 28 Oct 2023 17:08:00 +0100, Chris Green ha scritto:
>
> > I am using the python3 smbus module, but it's hard work because of the
> > lack of documentation. Web searches confirm that the documentation is
> > somewhat thin!
> >
> > If you do the obvious this is what you get:-
Dan Purgert wrote:
> On 2023-10-28, Chris Green wrote:
> > I am using the python3 smbus module, but it's hard work because of the
> > lack of documentation. Web searches confirm that the documentation is
> > somewhat thin!
> >
>
> The SMBus spec is available from http://smbus.org (or at least it
I have a couple of systems which used to have python2 as well as
python3 but as Ubuntu and Debian verions have moved on they have
finally eliminated all dependencies on python2.
So they now have only python3 and there is no python executable in
PATH.
There's still both /usr/bin/pip and /usr/bin/
Jon Ribbens wrote:
> On 2023-11-02, Dieter Maurer wrote:
> > Chris Green wrote at 2023-11-2 10:58 +:
> >> ...
> >>So, going on from this, how do I do the equivalent of "apt update; apt
> >>upgrade" for my globally installed pip packages?
> >
> > `pip list -o` will tell you for which packages
Jon Ribbens wrote:
> On 2023-11-02, Chris Green wrote:
> > I have a couple of systems which used to have python2 as well as
> > python3 but as Ubuntu and Debian verions have moved on they have
> > finally eliminated all dependencies on python2.
> >
> > So they now have only python3 and there is n
Jon Ribbens wrote:
> On 2023-11-02, Chris Green wrote:
> > Jon Ribbens wrote:
> >> On 2023-11-02, Chris Green wrote:
> >> > I have a couple of systems which used to have python2 as well as
> >> > python3 but as Ubuntu and Debian verions have moved on they have
> >> > finally eliminated all depe
Jon Ribbens wrote:
> On 2023-11-03, Karsten Hilbert wrote:
> > Am Thu, Nov 02, 2023 at 04:07:33PM -0600 schrieb Mats Wichmann via
> > Python-list:
> >> >So they now have only python3 and there is no python executable in
> >> >PATH.
> >>
> >> FWIW, for this you install the little stub package pyt
This is driving me crazy, I'm running this code:-
#!/usr/bin/env python3
#
#
# Show the electric fence history, default to last 24 hours
#
import sqlite3
import datetime
import sys
today = datetime.datetime.now()
Chris Green wrote:
> This is driving me crazy, I'm running this code:-
OK, I've found what's wrong:-
> cr.execute(sql, ('%' + "2023-11" + '%'))
should be:-
cr.execute(sql, ('%' + x + '%',) )
I have to say this seems very non-pythonesque to me, the 'obvious'
default simply doesn'
Stefan Ram wrote:
> Chris Green writes:
> >I have to say this seems very non-pythonesque to me, the 'obvious'
> >default simply doesn't work right, and I really can't think of a case
> >where the missing comma would make any sense at all.
>
> |6.15 Expression lists
> ...
> |an expression list co
Is there a neat, pythonic way to store values which are 'sometimes'
changed?
My particular case at the moment is calibration values for ADC inputs
which are set by running a calibration program and used by lots of
programs which display the values or do calculations with them.
From the program re
Thomas Passin wrote:
> On 12/5/2023 11:50 AM, MRAB via Python-list wrote:
> > On 2023-12-05 14:37, Chris Green via Python-list wrote:
> >> Is there a neat, pythonic way to store values which are 'sometimes'
> >> changed?
> >>
> >> My part
Paul Rubin wrote:
> Chris Green writes:
> > I could simply write the values to a file (or a database) and I
> > suspect that this may be the best answer but it does make retrieving
> > the values different from getting all other (nearly) constant values.
>
> I've used configparser for this, thou
Thank you everyone for all the suggestions, I now have several
possibilities to follow up. :-)
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Is there a way to abbreviate the following code somehow?
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
Chris Green wrote:
> Is there a way to abbreviate the following code somehow?
>
> lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
> sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
> la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
> sa = {'dev':'bbb', 'input'
Jon Ribbens wrote:
> On 2023-12-11, Chris Green wrote:
> > Chris Green wrote:
> >> Is there a way to abbreviate the following code somehow?
> >>
> >> lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
> >> sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
> >> la = {'dev'
Peter J. Holzer wrote:
> [-- text/plain, encoding quoted-printable, charset: us-ascii, 40 lines --]
>
> On 2023-12-29 09:01:24 -0800, Grant Edwards via Python-list wrote:
> > On 2023-12-28, Peter J. Holzer via Python-list
> > wrote:
> > > On 2023-12-28 05:20:07 +, rbowman via Python-list wr
I'm looking for a simple way to make NaN values output as something
like '-' or even just a space instead of the string 'nan'. This would
then make it much easier to handle outputting values from sensors when
not all sensors are present.
So, for example, my battery monitoring program outputs:-
dn wrote:
> On 18/02/24 09:53, Grant Edwards via Python-list wrote:
> > On 2024-02-17, Cameron Simpson via Python-list
> > wrote:
> >> On 16Feb2024 22:12, Chris Green wrote:
> >>> I'm looking for a simple way to make NaN values output as something
> >>> like '-' or even just a space instead of
Grant Edwards wrote:
> On 2024-02-16, Chris Green via Python-list wrote:
>
> > I'm looking for a simple way to make NaN values output as something
> > like '-' or even just a space instead of the string 'nan'.
>
> It would probably help if yo
Chris Angelico wrote:
> On Thu, 13 Jun 2024 at 10:58, wrote:
> >
> > Chris,
> >
> > You seem to have perceived an insult that I remain unaware of.
>
> If you're not aware that you're saying this, then don't say it.
>
Er, um, that really makes no sense! :-)
How can one not say something that on
I have a Raspberry Pi in my boat that uses I2C to read a number of
voltages and currents (using ADS1115 A2D) so I can monitor the battery
condition etc.
At present various different scripts (i.e. processes) just read the
values using the I2C bus whenever they need to but I'm pretty sure
this (quit
Piergiorgio Sartor
wrote:
> On 06/07/2024 09.28, Chris Green wrote:
> > I have a Raspberry Pi in my boat that uses I2C to read a number of
> > voltages and currents (using ADS1115 A2D) so I can monitor the battery
> > condition etc.
> >
> > At present various different scripts (i.e. processes) j
Lawrence D'Oliveiro wrote:
> On Sat, 6 Jul 2024 08:28:41 +0100, Chris Green wrote:
>
> > One fairly obvious way is to have single process/script which reads the
> > A2D values continuously and writes them to a file. All other scripts
> > then read from the file as needed, a simple file lock can
Stefan Ram wrote:
> Chris Green wrote or quoted:
> >That's exactly the sort of solution I was wondering about. Is there a
> >ready made module/library for handling this sort of thing? Basically
> >it will just be a string of a few tens of characters that would be
> >kept up to date by one proce
I have a Python script that filters my incoming E-Mail. It has been
working OK (with various updates and improvements) for many years.
I now have a minor new problem when handling E-Mail with a From: that
has accented characters in it:-
From: Sébastien Crignon
I use Python mailbox to pars
Stefan Ram wrote:
> Chris Green wrote or quoted:
> >From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?=
>
> In Python, when you roll with decode_header from the email.header
> module, it spits out a list of parts, where each part is like
> a tuple of (decoded string, charset). To smash these decod
I'm looking for Python packages that can help with text mode input,
i.e. for use with non-GUI programs that one runs from the command
prompt in a terminal window running a bash shell or some such.
What I'm specifically after is a way to provide a default value that
can be accepted or changed easil
Can one use pipx to wrap the process of creating an independent
environment for a python package as opposed to a runnable application?
E.g. I want to install and use pksheet but, as it's not available from
the Debian repositories, I'll have to install it from PyPi. So I
should put it in its own e
Peter J. Holzer wrote:
> [-- text/plain, encoding quoted-printable, charset: us-ascii, 32 lines --]
>
> On 2025-01-14 11:32:35 +0000, Chris Green via Python-list wrote:
> > Use a virtual environment, what do I have to do then to make using
> > my program (t
Stefan Ram wrote:
> Chris Green wrote or quoted:
> >E.g. I want to install and use pksheet but, as it's not available from
> >the Debian repositories, I'll have to install it from PyPi.
>
> I can't dig up any "pksheet" on PyPI. So, you got to take
> my earlier response like a rumor from a ra
rustbuck...@nope.com wrote:
>
> This is what I was going to suggest. Rich is super easy to use.
OK, thanks, Rich is on my shortlist then.
--
Chris Green
·
--
https://mail.python.org/mailman/listinfo/python-list
Alan Gauld wrote:
> On 14/01/2025 00:20, Grant Edwards via Python-list wrote:
> > On 2025-01-13, Alan Gauld via Python-list wrote:
> >
> >> All of that is possible in curses, you just have to code it.
> >
> > All of that is easy with curses in C. Unfortunately, the high level
> > "panel" and "
I have a (relatively) clean Debian 12 installation running on my two
workhorse systems, a desktop server at home and my laptop that travels
around with me.
I moved from Xubuntu to Debian on both these systems a few months ago.
I ran Xubuntu for many years and acquired a whole lot of python
packa
Cameron Simpson wrote:
> On 25Dec2024 14:52, Abdur-Rahmaan Janhangeer wrote:
> >I have been following discussions on Discourse (discuss.python.org)
> >these last times.
> >
> >I think that it definitely lacks some of the joys of the mailing list:
>
> FYI, it has a very good "mailing list" mode.
45 matches
Mail list logo