Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It's not really a rule--it's more like a trend. -- Larry Wall in <199710221721.KAA24321@wall.org>


devel / comp.lang.python / How/where to store calibration values - written by program A, read by program B

SubjectAuthor
* How/where to store calibration values - written by program A, read by program BChris Green
+- Re: How/where to store calibration values - written by program A, read by prograStefan Ram
+- Re: How/where to store calibration values - written by program A,MRAB
+* Re: How/where to store calibration values - written by program A, read by prograPaul Rubin
|`- Re: How/where to store calibration values - written by program A, read by prograChris Green
+- Re: How/where to store calibration values - written by program A,Mats Wichmann
+- Re: How/where to store calibration values - written by program A,Barry Scott
+- Re: How/where to store calibration values - written by program A,DL Neil
+* Re: How/where to store calibration values - written by program A,DL Neil
|`- Re: How/where to store calibration values - written by program A, read by prograChris Green
`* Re: How/where to store calibration values - written by program A,Thomas Passin
 `* Re: How/where to store calibration values - written by program A, read by prograChris Green
  +* Re: How/where to store calibration values - written by program A, read by prograStefan Ram
  |`- Re: How/where to store calibration values - written by program A,Dan Purgert
  +- Re: How/where to store calibration values - written by program A,2QdxY4RzWzUUiLuE
  +- Re: How/where to store calibration values - written by program A,Barry Scott
  +- Re: How/where to store calibration values - written by program A,Thomas Passin
  +- Re: How/where to store calibration values - written by program A,MRAB
  +- Re: How/where to store calibration values - written by program A,dn
  +- Re: How/where to store calibration values - written by program A,MRAB
  +- Re: How/where to store calibration values - written by program A,Thomas Passin
  +- Re: How/where to store calibration values - written by program A,Peter J. Holzer
  +* A problem with str VS int.Steve GS
  |`- Re: A problem with str VS int.Stefan Ram
  +- RE: A problem with str VS int.<avi.e.gross
  +- Re: A problem with str VS int.Thomas Passin
  +- Re: A problem with str VS int.dn
  +* IDLE editor suggestion.Steve GS
  |+- Re: IDLE editor suggestion.Stefan Ram
  |`* Re: IDLE editor suggestion.Stefan Ram
  | `- Re: IDLE editor suggestion.Stefan Ram
  +- RE: A problem with str VS int.Steve GS
  +- Re: A problem with str VS int.Roel Schroeven
  +- Re: A problem with str VS int.dn
  +- RE: A problem with str VS int.<avi.e.gross
  +- Re: IDLE editor suggestion.MRAB
  +- Re: IDLE editor suggestion.Friedrich Romstedt
  +- Re: IDLE editor suggestion.Thomas Passin
  +- Re: IDLE editor suggestion.Mats Wichmann
  +- RE: IDLE editor suggestion.Steve GS
  `- Re: IDLE editor suggestion.MRAB

Pages:12
How/where to store calibration values - written by program A, read by program B

<r5p34k-5li5.ln1@esprimo.zbmc.eu>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.furie.org.uk!nntp.terraraq.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: How/where to store calibration values - written by program A, read by program B
Date: Tue, 5 Dec 2023 14:37:15 +0000
Lines: 21
Message-ID: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 956zLAsqwnkpB4zL6SeJiA1yzS3oYm6RR+Zs1gEhkP0m0uB48=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:jxzd/7bY4kEmYL2w3PKjxc1s2B4= sha256:a/w6+vlTE8bAzFZD5JpXDNIAzrdKxNNirdlLGpJbMto=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-89-generic (x86_64))
 by: Chris Green - Tue, 5 Dec 2023 14:37 UTC

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 readability point of view it would be good to have a
Python module with the values in it but using a Python program to
write/update a Python module sounds a bit odd somehow.

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.

Are there any Python modules aimed specifically at this sort of
requirement?

--
Chris Green
·

Re: How/where to store calibration values - written by program A, read by program B

<perm-20231205163734@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A, read by program B
Date: 5 Dec 2023 15:47:49 GMT
Organization: Stefan Ram
Lines: 54
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <perm-20231205163734@ram.dialup.fu-berlin.de>
References: <r5p34k-5li5.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 dWdIgHYXofIjR4drBWx/Pgt+laRjYj1ah2RF0Z2a7Hf7So
Cancel-Lock: sha1:B+iP24E8UGXMQMvYbBAVR2hHkJE= sha256:n2g7gLTIkFWyCl2lh+43KhEtdaL0NIwAgMw/CnUtPyA=
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 - Tue, 5 Dec 2023 15:47 UTC

Chris Green <cl@isbd.net> writes:
>Is there a neat, pythonic way to store values which are 'sometimes'
>changed?

If you're comfortable with SQL, there is sqlite.

I'd write a small wrapper class around it, so that only this
wrapper comes in contact with any SQL. Then you can change
it later to store data in some other way (if necessary).

>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.

They are not /constant/ values.

When I was young and started to learn BASIC, one of the first
idea for my own programming language was the possibility to
define durations for variables. For example,

perm int i;

. Being declared "perm", your variable "i" now keeps its value
across program instances. So, when you say, "i = 27;", and do
not change it afterwars, and only one instance of your program
is running, next time you start your program, "i" will be 27.

A lazy way to save values would be to use one value per file.
(You do not need a special language like JSON, then.)

# WARNING: DO NOT RUN! (Program will override files named "x" and "y"!)

def load( filename ):
try:
with open( filename )as input_stream:
result = int( next( input_stream ))
except FileNotFoundError:
result = 0
return result

def save( value, filename ):
with open( filename, 'w' )as output_stream:
print( value, file=output_stream )

x = load( "x" )
y = load( "y" )
print( f'{x=}' )
print( f'{y=}' )
x += 1
y -= 1
save( x, "x" )
save( y, "y" )

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Tue, 5 Dec 2023 16:50:06 +0000
Lines: 33
Message-ID: <mailman.325.1701795196.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de /qtXTHT4fxL1oxS0ZUmdFA/T53XY7k+9Mh+QVKzhjYIw==
Cancel-Lock: sha1:Sn1+ktlUQn5E+pKThTzrcEBmdLU= sha256:BGvOKiisBi/0d56hMRWcaVS1YlAMnGLJ+snpG2Yp/8Q=
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=cnX2Ddfl;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "python's": 0.05;
'modules': 0.07; '(python': 0.09; 'aimed': 0.09;
'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
'subject:, \n ': 0.09; 'values.': 0.09; 'calculations': 0.16;
'constant': 0.16; 'from:addr:mrabarnett.plus.com': 0.16;
'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16;
'odd': 0.16; 'personally,': 0.16; 'pythonic': 0.16; 'readability':
0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16;
'received:plus.net': 0.16; 'somehow.': 0.16; 'sounds': 0.16;
'subject:program': 0.16; 'subject:values': 0.16; 'wrote:': 0.16;
'python': 0.16; 'values': 0.17; 'to:addr:python-list': 0.20;
'lines': 0.23; 'subject:How': 0.23; "i'd": 0.24; 'solution.':
0.26; 'suspect': 0.26; 'bit': 0.27; 'chris': 0.28; 'suggest':
0.28; 'header:User-Agent:1': 0.30; 'module': 0.31; 'program':
0.31; 'python-list': 0.32; "wouldn't": 0.32; 'received:192.168.1':
0.32; 'but': 0.32; 'there': 0.33; 'particular': 0.33; 'header:In-
Reply-To:1': 0.34; 'running': 0.34; 'display': 0.36; 'using':
0.37; 'received:192.168': 0.37; 'file': 0.38; 'way': 0.38;
'could': 0.38; 'view': 0.60; 'best': 0.61; 'simply': 0.63;
'subject:read': 0.69; 'read,': 0.75; 'database': 0.80; 'moment':
0.81; 'inputs': 0.84; 'subject:where': 0.84; 'of:': 0.91; 'green':
0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1701795007; bh=5gSNJ+0XYTS76TLvvZP742lqTYEIzx1FlYSfs94pSBo=;
h=Date:Subject:To:References:From:In-Reply-To;
b=cnX2DdflWRhC+ntuHdTPksCzOon73PUaXfgIbJecQSeqllgpNgukAtDwy3AeEf+Y9
45kL7k04H2Ldl4i6F+Ha/Bx2BDRMPXIJlItB9FZEdlpPZ5baWjI8ll6aYZJw9qtpWy
o/pl2Cv68LHc0RRnW64WOADPS0XYmvKbUofraCFqWeNB0FGw6w1dUMkMh7wUAIcTz+
A0qmxEcSMheKhPhw6KfakVsQD79sTg1/T2DmO0ql9VNHmM5WZMlXIoWpScSiPRVZ0b
JQ45nP5C2ErFBmZks8GGI63FwkKIi9URc+l+pvZbX9+FrBRixC9yN1aZRlxrg+EOnE
ZoYAnnc7wQsDQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=UtZwis8B c=1 sm=1 tr=0 ts=656f54bf
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=WcwXd8KSL0qryYcVsP0A:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
X-CMAE-Envelope: MS4xfBlEXgVPs7Qja3pxFCIF+y3WWCVEaw7y1NXc12NATy7jN6I1AAoYrPmYxnswP8d6HxA/QAcdUMSTJtYBDpTVVEHWz7udXeZHKLwxgRvPj//VROOELECD
yMXoFosJ2RwyfTukxvilkGtcJuZQR+3/ff/2haoLvl1QYenVNlQQ0ENwPOmwV1XOdRU/vNHBDSoOfSfgP16fiSrGUdkzA2Ffn78=
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: <459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
 by: MRAB - Tue, 5 Dec 2023 16:50 UTC

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 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 readability point of view it would be good to have a
> Python module with the values in it but using a Python program to
> write/update a Python module sounds a bit odd somehow.
>
> 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.
>
> Are there any Python modules aimed specifically at this sort of
> requirement?
>
Some kind of key/value store sounds like the correct solution. I
wouldn't go as far a database - that's overkill for a few calibration
values.

I might suggest TOML, except that Python's tomllib (Python 3.11+) is
read-only!

Personally, I'd go for lines of:

key1: value1
key2: value2

Simple to read, simple to write.

Re: How/where to store calibration values - written by program A, read by program B

<87r0k05sw7.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A, read by program B
Date: Tue, 05 Dec 2023 11:52:24 -0800
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <87r0k05sw7.fsf@nightsong.com>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e5b2fc88e48b842c4e76d85db28f2b30";
logging-data="406903"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tz+prpHoga6Epf/SW8KNj"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:YwmgGw7FrgpFWacbsKM0FdOqLBk=
sha1:uU3Z6d/d3nNcegKgyMBSHYL3QxA=
 by: Paul Rubin - Tue, 5 Dec 2023 19:52 UTC

Chris Green <cl@isbd.net> 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, though its intention is files that are
manually edited, rather than updated by a program.

You can also read and dump a json file or pickle file. I prefer json to
pickle for most purposes these days.

I don't like YAML and I don't like the proliferation of markup formats
of this type. So while I don't know exactly what TOML is, I figure it
must be bad.

I sometimes use ast.literal_eval though it is Python specific.

Of course there is also sqlite but that is probably overkill.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: mats@wichmann.us (Mats Wichmann)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Tue, 5 Dec 2023 13:30:53 -0700
Lines: 26
Message-ID: <mailman.326.1701808394.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<491a7766-f477-4973-9e8f-8a35feac924a@wichmann.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de sEvAu7UjDJWvfXYRk+su8AVRJYuwr/+s/IsoS6OULg8Q==
Cancel-Lock: sha1:uGGEsjdvpmKpe5GAxH6fV52y3OQ= sha256:9hkqij8L8BrazzyAV9uaHH1Q+1iALYuwzd6dGWVgPHw=
Return-Path: <mats@wichmann.us>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=pobox.com header.i=@pobox.com header.b=lnEJA9ek;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.011
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'csv': 0.03; 'modules':
0.07; 'aimed': 0.09; 'json': 0.09; 'subject:, \n ': 0.09;
'values.': 0.09; '"data': 0.16; 'calculations': 0.16; 'constant':
0.16; 'mentioned,': 0.16; 'odd': 0.16; 'pythonic': 0.16;
'readability': 0.16; 'received:64.147': 0.16; 'somehow.': 0.16;
'sounds': 0.16; 'subject:program': 0.16; 'subject:values': 0.16;
'wrote:': 0.16; 'python': 0.16; 'values': 0.17; 'to:addr:python-
list': 0.20; 'subject:How': 0.23; 'suspect': 0.26; 'bit': 0.27;
'chris': 0.28; 'header:User-Agent:1': 0.30; 'module': 0.31;
'program': 0.31; 'python-list': 0.32; 'but': 0.32; 'there': 0.33;
'particular': 0.33; 'header:In-Reply-To:1': 0.34; 'running': 0.34;
'display': 0.36; 'using': 0.37; 'received:192.168': 0.37; 'file':
0.38; 'way': 0.38; 'could': 0.38; 'text': 0.39; 'use': 0.39;
'view': 0.60; 'best': 0.61; 'search': 0.61; "there's": 0.61;
'data,': 0.63; 'simply': 0.63; 'look': 0.65; 'received:64': 0.67;
'subject:read': 0.69; 'database': 0.80; 'moment': 0.81; 'inputs':
0.84; 'subject:where': 0.84; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id
:date:mime-version:subject:to:references:from:in-reply-to
:content-type:content-transfer-encoding; s=sasl; bh=DU+SMBse0Q35
SQTEdDpWTpVeVWD7pbACJ4T2kA+Wyo8=; b=lnEJA9ekD/QY+7oaMjuy/GeY8Kui
JDrAZbJWc/QKf55SSXHhm32yn9WWaZ6CCXWDOSvuP2j3sMPB2n1fGjwb8jASI4Su
tcGegNu0JE0ayoOa628y0fnST3huQbKg6AU+Z4IhKnFpzvc4n9N4WQPcO9IwhQAi
VtgFen6NRS0J+T0=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=wichmann.us;
h=message-id:date:mime-version:subject:to:references:from:in-reply-to:content-type:content-transfer-encoding;
s=2018-07.pbsmtp; bh=DU+SMBse0Q35SQTEdDpWTpVeVWD7pbACJ4T2kA+Wyo8=;
b=BX/PFCKjv/VyvkUoauXXEctgwJ2T7l+qvE1pnSKOjE85NzzqReZTp7lLKKjnzS9Jttle28uPfdiXsIL6SMfkOmtIPmI1Q6wo7y5TM2sKCkFzGjk6guu4TzLO41CzmN9iQ9DB24jjAv/dOHCiUGLZCs4egZzqBwaDtU4idNT4Dpo=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Autocrypt: addr=mats@wichmann.us; keydata=
xsDiBD9xp6oRBAC1vd3YI8Gcr1CxpV1gldNQu0uQsNaICDk+Ai3+R163s/P83JOYG+SBEA3P
v7iZx70qpQ3RzP7KrjF1Nm6j0em9ccUX2fPQUCAxXw5Hiq7CSMiwQQZRI6shcnyMh9XTKViT
WK5MrKDyvjDEn7epjKzKwPS5SG039l6XaOKU0A4uGwCgsNqUQqC0gMMcbKlJV8ql58iKmbMD
/ii8FPQrXmyS/FnsPs7UddV5qMHKm7NUH5oiKuMVyakInRyq9iIxuu3D4Ec6mWRKcGsjmIkW
HXCSz0aefs6dsqNqpU54cYioJ3wP5LzHK7oclgJPryVt5Qezbdutf8SQf8gVkaNIlkxwGUzi
bKTZ6CHzwlz9nNgeel0XPUcZzFxGA/4paeCg2rMSVuAhUQbsLYHu4XzTs9P16zaXkrtxc4m5
b+BF5xsLgTpyO5l859XudS2Gp+7/Y37dAU4QlyGGOboWmF1y9U5DnzBwG8ghsnym+ga58MJh
LdRdQQ6xQolCpEXOuzm40f2r5uMxF3KOJ7WpIPuGAkeCPru9BmlATH+zOs0gTWF0cyBXaWNo
bWFubiA8bWF0c0B3aWNobWFubi51cz7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX
gAUCT0VyZwIZAQAKCRDAMaCQc9hUxiZBAJ9cWziGp7hVfsu5T+cQptc3rLNndQCgrZh8u5LW
BfJ5e/Y+3PwZ8UEm+ELOwE0EP5is8BAEAMtwzcA8TYf5UTjDMgwcSNoErTc9ag+IX05QFgL8
aF8sfJRv5atcitqQy0gSIsOzI+L/AFdPN/+QQI3dL1tCq14t32KPDtigDhzm6jVPXX5z+V9u
xnD8XTp+ZvNcWoHXjViM8aXeLLEiCpiVCho307h3XShvqoKINWRQWeAsKKDDAAMFA/48zaey
wiiEyvI0meJ1KkNHxdLP0yLODr1WV6j9xkPkLWOaIDw7dlwEOlF1N1YtZ2wa0p1wsttdIbIx
ffgwXmcH4zrdxUIMz3U0BqYzk5H+5cYFXECXTFVOmweS+JECYMj80PjRoKCO1eVO1N30zksB
36NnhZWPRWIhjK3ZarIYH8JGBBgRAgAGBQI/mKzwAAoJEMAxoJBz2FTG6VEAoKDYHfDp5Q3q
PuPvPahCE9HsXMgAAJ9INTqcLSJrOfyJ8q95nBO1T26H2Q==
In-Reply-To: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
X-Pobox-Relay-ID: 3044B504-93AD-11EE-A6F5-25B3960A682E-81526775!pb-smtp2.pobox.com
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: <491a7766-f477-4973-9e8f-8a35feac924a@wichmann.us>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
 by: Mats Wichmann - Tue, 5 Dec 2023 20:30 UTC

On 12/5/23 07:37, Chris Green via Python-list wrote:
> 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 readability point of view it would be good to have a
> Python module with the values in it but using a Python program to
> write/update a Python module sounds a bit odd somehow.
>
> 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.
>
> Are there any Python modules aimed specifically at this sort of
> requirement?

A search term to look for is "data persistence"

there is lots of support at various levels - you can do simpler things
with plain text (or binary), json data, or csv data, or configparser, or
use pickles; if there's not a lot of values a dbapi database may, as
already mentioned, be overkill.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  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: barry@barrys-emacs.org (Barry Scott)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Tue, 5 Dec 2023 20:45:36 +0000
Lines: 33
Message-ID: <mailman.327.1701809804.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<1D62AAD1-C652-4664-ADC7-2B9A92B49358@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de PIa9v/KKkuiLrt7LYo/jHg+ct79MDyF1LhEDHtAGo5PA==
Cancel-Lock: sha1:wOpS2HgzC1bTxPV7Zm7EFfaUQkE= sha256:As8FHpsHCWt/yrWLv9NGBXOtpfey2S1dBz+0cd6Xt1s=
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'modules': 0.07; 'thing.':
0.07; 'aimed': 0.09; 'cc:addr:python-list': 0.09; 'example:':
0.09; 'from:addr:barry': 0.09; 'json': 0.09; 'received:217.70':
0.09; 'received:217.70.178': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'subject:, \n ': 0.09; 'cc:no
real name:2**0': 0.14; 'import': 0.15; 'barry': 0.16; 'from:addr
:barrys-emacs.org': 0.16; 'from:name:barry scott': 0.16; 'message-
id:@barrys-emacs.org': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'wrote:<span': 0.16; 'wrote:': 0.16;
'python': 0.16; 'cc:addr:python.org': 0.20; 'subject:How': 0.23;
'cc:2**0': 0.25; 'chris': 0.28; 'email addr:python.org&gt;': 0.28;
'suggest': 0.28; 'dec': 0.31; 'saved': 0.31; 'python-list': 0.32;
'there': 0.33; '0);': 0.33; 'rgb(0,': 0.33; 'header:In-Reply-
To:1': 0.34; 'read': 0.38; 'use': 0.39; 'font-family:': 0.60;
'inline': 0.61; 'display:': 0.62; 'none;': 0.62; 'font-weight:':
0.62; '0px;': 0.63; 'text-indent:': 0.64; 'normal;': 0.66;
'received:217': 0.67; 'skip:! 10': 0.67; 'subject:read': 0.69;
'float:': 0.74; 'skip:! 20': 0.81; 'email name:&lt;python-list':
0.84; 'subject:where': 0.84; '400;': 0.89; '13px;': 0.91; 'tend':
0.91; 'green': 0.96
In-Reply-To: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
X-Mailer: Apple Mail (2.3774.200.91.1.1)
X-GND-Sasl: barry@barrys-emacs.org
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <1D62AAD1-C652-4664-ADC7-2B9A92B49358@barrys-emacs.org>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
 by: Barry Scott - Tue, 5 Dec 2023 20:45 UTC

> On 5 Dec 2023, at 14:37, Chris Green via Python-list <python-list@python.org> wrote:
>
> Are there any Python modules aimed specifically at this sort of
> requirement?

I tend to use JSON for this type of thing.
Suggest that you use the options to pretty print the json that is saved so that a human can read it.

For example:
----
import json

config = {
'key2': 42,
'key1': 'value 1',
}

print(json.dumps(config, indent=4, separators=(', ', ': '), sort_keys=True))

----
% python $T/a.py
{ "key1": "value 1",
"key2": 42
}

Barry

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (DL Neil)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 09:54:38 +1300
Lines: 51
Message-ID: <mailman.328.1701810243.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 7ivxFlKDvmUg/+GinCOCMA/MS7ggZVG9IqrPTT2tIDVQ==
Cancel-Lock: sha1:kSTg6AORAU3tCummOakOQ8MOI1Q= sha256:QgxR1jwn3VYkT6mPh/lKw6kovxjtQPAw4jADkU6C7AA=
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=SCdGgbpf; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'formal': 0.07;
'libraries.': 0.07; 'modules': 0.07; '=dn': 0.09; 'aimed': 0.09;
'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
0.09; 'from:name:dl neil': 0.09; 'received:192.168.1.64': 0.09;
'subject:, \n ': 0.09; 'values.': 0.09; '(b)': 0.16;
'calculations': 0.16; 'constant': 0.16; 'dictionary,': 0.16;
'humans': 0.16; 'message-id:@DancesWithMice.info': 0.16; 'odd':
0.16; 'pythonic': 0.16; 'readability': 0.16; 'received:cloud':
0.16; 'received:rangi.cloud': 0.16; 'results,': 0.16; 'similar,':
0.16; 'somehow.': 0.16; 'sounds': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'variables,': 0.16; 'wrote:': 0.16;
'python': 0.16; 'values': 0.17; 'code.': 0.17; 'to:addr:python-
list': 0.20; 'machine': 0.22; "i've": 0.22; 'first,': 0.22;
'maybe': 0.22; 'ran': 0.22; 'subject:How': 0.23; 'suspect': 0.26;
'bit': 0.27; 'chris': 0.28; 'output': 0.28; 'environment': 0.29;
'recently': 0.29; 'header:User-Agent:1': 0.30; 'seem': 0.31;
'module': 0.31; 'program': 0.31; '(as': 0.32; 'assume': 0.32;
'python-list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32;
'there': 0.33; 'particular': 0.33; 'header:In-Reply-To:1': 0.34;
'running': 0.34; 'meaning': 0.35; 'files': 0.36; 'display': 0.36;
'using': 0.37; 'received:192.168': 0.37; 'file': 0.38; 'way':
0.38; 'could': 0.38; 'changes': 0.39; 'single': 0.39; 'use': 0.39;
'still': 0.40; 'level.': 0.40; 'teams': 0.40; 'view': 0.60;
'best': 0.61; 'search': 0.61; 'likely': 0.61; "there's": 0.61;
'simply': 0.63; 'number,': 0.64; 'your': 0.64; 'top': 0.65;
'outside': 0.67; 'choose': 0.67; 'settle': 0.69; 'subject:read':
0.69; 'tools': 0.74; 'yes': 0.76; 'significant': 0.78; '(c)':
0.81; 'leads': 0.81; 'moment': 0.81; 'continuity': 0.84;
'elsewhere.': 0.84; 'experience:': 0.84; 'inputs': 0.84; 'pairs':
0.84; 'subject:where': 0.84; 'green': 0.96
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud F2C177069
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1701809684;
bh=keWNvHsAGmDlF348xTovv+O94G25wumq1+2q9NEkul4=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=SCdGgbpfMgBxW/CgNWAica88Dyz5D+Ez34z3bRKFQYDyddiRX6Sny1MumCZhKoAwe
sVmCRlLFgHwMBWK3uJRtHdMSqTwqXLaX6nAQfDT7wmTA5KizPb/jU5C/WuTjoG5GSV
xIUpizuqAj98pbLaG22g4ML923wqWSHMI++coO+qNu1CW8EJb39o7Ik5PpMGAz9bBv
kQGvojLkQTanecFHGbKVEG7obAgIj86O/VzDY4B//avGXzCtbuYRwAXdRiwbt+7N5K
R4sLLsRBLVfu8D1Gj7ngoNXrxwLLEO4JA+GPPjDRLYFZhi7X18g283zKvD8UqrhxB1
Bs2/nbz4FSTTQ==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <r5p34k-5li5.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: <fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
 by: DL Neil - Tue, 5 Dec 2023 20:54 UTC

On 12/6/23 03:37, Chris Green via Python-list wrote:
> 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 readability point of view it would be good to have a
> Python module with the values in it but using a Python program to
> write/update a Python module sounds a bit odd somehow.
>
> 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.
>
> Are there any Python modules aimed specifically at this sort of
> requirement?

Another programming-term for these might be "environment variables".
However, be aware that such also has a specific meaning at the Operating
System level.

1 Sysops Environment Variables exist completely outside the code. Python
interrogates the Sysops to fetch/set them. Can be problematic because
only apply on single machine and are not part of change-control, VS, etc.

2 A .con file (in my tradition, likely still .uni type in MSFT) or
similar, which contains the key:value pairs recommended elsewhere. There
are formal .con and .uni (etc) formats. Most of the teams I've
worked-with recently seem to settle on .JSON files which are
very-conveniently structured as (read into/written from) a Python
dictionary, and a single function-call interaction.

Word of warning/voice of [bitter] experience: ALWAYS *trumpet* any
changes in these values AND output them (as you would any "assumptions"
for a calculation) at the top of output reports. The trouble is that
humans assume continuity but such an arrangement is NOT idempotent -
which leads to complaints: "I ran it on Monday and got these results,
but when I ran it again on Tuesday, the results changed"...

Yes there are Python libraries. Choose your method/format first, and
then search - either Duckboards or straight from Pepi.

I have systems which use an DBMS for environment variables, but (a) only
when there's a significant number, and (b) when the application is
already connecting to the DBMS for processing [and maybe (c) because I
know my way around such tools so they're 'easy']. Not recommended!

--
Regards =dn

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (DL Neil)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 10:08:12 +1300
Lines: 7
Message-ID: <mailman.329.1701810499.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info>
<3563e673-112d-4cfc-b30a-c5394d6c35ff@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de AODWSSfa5AJKtuaU3tpH6ggUDCc+h1KfAY4SbsRvBWLQ==
Cancel-Lock: sha1:2h6Y55+OqteiC7PPNI2Ut/SoGio= sha256:b3RXOMi/UjDAWqW9OjSElhaj3DHvscV0zDjUpV0WMuY=
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=Fm7ljPoo; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '=dn': 0.09;
'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
0.09; 'from:name:dl neil': 0.09; 'received:192.168.1.64': 0.09;
'subject:, \n ': 0.09; 'url-ip:151.101.0.223/32': 0.09; 'url-
ip:151.101.128.223/32': 0.09; 'url-ip:151.101.192.223/32': 0.09;
'url-ip:151.101.64.223/32': 0.09; 'message-
id:@DancesWithMice.info': 0.16; 'received:cloud': 0.16;
'received:rangi.cloud': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'url:project': 0.16; 'url:pypi': 0.16;
'to:addr:python-list': 0.20; 'subject:How': 0.23; 'header:User-
Agent:1': 0.30; 'url-ip:188/8': 0.31; 'received:192.168.1': 0.32;
'header:In-Reply-To:1': 0.34; 'received:192.168': 0.37; 'url-
ip:151.101.0/24': 0.62; 'url-ip:151.101.128/24': 0.62; 'url-
ip:151.101.192/24': 0.62; 'url-ip:151.101.64/24': 0.62;
'subject:read': 0.69; 'subject:where': 0.84
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud CC51A135D
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1701810497;
bh=nRmH+WcUjfM96Ih6LnfeSC8/0N7Vdn1xOVsgvvq6Jrw=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=Fm7ljPoo8Naacneie6csgD/Yt/81LNjjcW8rl2OYovtzX1rOSIfokuR+eqatF/c8D
UJT7JFTrDmWc6UudCQWDRHQVlufTT9iZwcyY0I0OHuZ/PcJ/gib+WYel7SQ2hukSyx
Vuew4bAacUOZSenPCDaKhAYBWJm5UWqj7yZ3SjxSM61fnl2sumBwM/0AtKtoijCBJX
xRGyhhio7LWr+nU6JMP4fY8l81/uBqAYCv0/hiBNAGuaO2cXkUHGclr5u5OcXFykIZ
4+/mcNd9yq/tmWXYov2uRgDyfTaIuj8GPAQ9FPWdFvFmbdEveJ6fBv1SosL3o85aUM
qQajBUlep2O1A==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info>
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: <3563e673-112d-4cfc-b30a-c5394d6c35ff@DancesWithMice.info>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info>
 by: DL Neil - Tue, 5 Dec 2023 21:08 UTC

Apologies: neglected suggested web.refs:

https://datagy.io/python-environment-variables/
https://pypi.org/project/json_environ/

--
Regards =dn

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.chmurka.net!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Tue, 5 Dec 2023 18:56:14 -0500
Lines: 37
Message-ID: <mailman.330.1701836673.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de LNfveigzvqoQTsUL/UM87AYsQshZMknRzFsnTjy2k9RQ==
Cancel-Lock: sha1:2oi4ANBAgt9srxta/YBWtBS3RVA= sha256:Z0c1naSkB4WfI7yBPrjJ0w2eTr2kfZ717GGX3mCKd1k=
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=oGCx06fw;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'library.': 0.05;
"python's": 0.05; 'modules': 0.07; '(python': 0.09; 'aimed': 0.09;
'received:23.83.212': 0.09; 'received:elm.relay.mailchannels.net':
0.09; 'subject:, \n ': 0.09; 'values.': 0.09; 'calculations':
0.16; 'constant': 0.16; 'odd': 0.16; 'personally,': 0.16;
'pythonic': 0.16; 'readability': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'somehow.': 0.16; 'sounds': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values':
0.17; 'to:addr:python-list': 0.20; 'lines': 0.23; 'subject:How':
0.23; "i'd": 0.24; 'solution.': 0.26; 'suspect': 0.26; 'bit':
0.27; 'chris': 0.28; 'suggest': 0.28; 'header:User-Agent:1': 0.30;
'am,': 0.31; 'module': 0.31; 'program': 0.31; 'python-list': 0.32;
'received:10.0': 0.32; 'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'simple,': 0.32;
"wouldn't": 0.32; 'but': 0.32; 'there': 0.33; 'particular': 0.33;
'header:In-Reply-To:1': 0.34; 'running': 0.34; 'display': 0.36;
'using': 0.37; 'file': 0.38; 'way': 0.38; 'could': 0.38; 'view':
0.60; 'best': 0.61; 'gives': 0.62; 'simply': 0.63;
'header:Received:6': 0.67; 'received:64': 0.67; 'subject:read':
0.69; 'read,': 0.75; 'database': 0.80; 'moment': 0.81; 'inputs':
0.84; 'subject:where': 0.84; 'of:': 0.91; 'green': 0.96
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1701820576; a=rsa-sha256;
cv=none;
b=uPuDf2VFxG4pRR4KDW4BDiyv88PWPstK9bKfS76md833SUiN4A5ENQk9bA8WntWGOzQ5HY
9d6tnTdU9nX1e2bhf4TKwcsDaLgYDPpY6Dgu6Mcurab2QA1COrTWvZLxD6LN7TJgCObKVv
OZq3wKZyd7uB8pKtNChx+su9Q4gUu4g0BWWreD5i4zvcdUcO1lNKnhaGmqJ1EJcdBIbYOb
l1ZTlCPOboeUTpuor6zkOkhvYQFNJSLI8v/4Rca6wyBioIJh6t4ApgbLFBCGy3IVgArQRE
K0877TH7iSzkvVghSpjb5auX5j/KsBFBTC7ei+CFxWjEqNTYfKuk89BlhAAzLw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1701820576;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=dYAGNhSBtWBoaHW7jw+qrK+/q9OUFBQRYGWwWuc4rvg=;
b=bQDvi8X0MbUlkOn0K3iS5JAvSnMccHWyAKXg8+UKuRWRn5PrNPob3AJWvS2lRBQ5RBjlTP
iwg1AstgWDt6QIlRXiv6sQc9Nir0F+4ZU3D+dMTshMIftFKU0yBnErIoh20fkhuaAXnr3j
cyn3a9M/FSARdrbFkZYZSWYO5m4l/08p74p1uYmqsgNewq4e73f+XDCddRi4/Icgez9J9J
r+5jd5669jKnNHa+nCvvUEbensCilUAfPYeA/7katMZ7VT94j3icQ5KfxqQhDFIQkV5lBe
zbQH5pii4PchDe1JMg8B57RXRWuiUJ8boBzglm46Dk52lzH0PBd8MCNSanO6Kw==
ARC-Authentication-Results: i=1; rspamd-696ff67dc8-tzxpm;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Ruddy-Befitting: 690a90ed4ba990f3_1701820576738_64190072
X-MC-Loop-Signature: 1701820576738:3180333352
X-MC-Ingress-Time: 1701820576738
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1701820576;
bh=dYAGNhSBtWBoaHW7jw+qrK+/q9OUFBQRYGWwWuc4rvg=;
h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding;
b=oGCx06fwXg8Q0s9UuBYb+7185MXMC2U+P+f9TR3sQjkRd7rHpWZ+IIYzfyMfPkeKL
nfX8HiiUm7sqoBOlRQ3fPHdwlCGR6HW8F6/5j0tnnrFUgtWp8NAdX1Nc9tJYaU3Uot
QvZqE2vXtsi/fzUcvVscHyoGidhr8H3Glx/MDt5bQaZ6LL0YZ1p/oeSEcVxXFDdYfU
6f9gZv0FdEP/yd1E+oDHavVl5j2T7BRdLGIw6v14pMpAZriRC36EXZ//RlDdlbJM0D
kYB8/+obnbpJ+JMGjPuoB0N2AiEfRKJPfn4f+QCikJlA53PTK1IiOvstJYlpT/iPUc
MtjsncJlkTydw==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
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: <6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
 by: Thomas Passin - Tue, 5 Dec 2023 23:56 UTC

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 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 readability point of view it would be good to have a
>> Python module with the values in it but using a Python program to
>> write/update a Python module sounds a bit odd somehow.
>>
>> 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.
>>
>> Are there any Python modules aimed specifically at this sort of
>> requirement?
>>
> Some kind of key/value store sounds like the correct solution. I
> wouldn't go as far a database - that's overkill for a few calibration
> values.
>
> I might suggest TOML, except that Python's tomllib (Python 3.11+) is
> read-only!
>
> Personally, I'd go for lines of:
>
>     key1: value1
>     key2: value2
>
> Simple to read, simple to write.

Just go with an .ini file. Simple, well-supported by the standard
library. And it gives you key/value pairs.

Re: How/where to store calibration values - written by program A, read by program B

<ilr54k-24m9.ln1@esprimo.zbmc.eu>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!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: Re: How/where to store calibration values - written by program A, read by program B
Date: Wed, 6 Dec 2023 09:32:02 +0000
Lines: 55
Message-ID: <ilr54k-24m9.ln1@esprimo.zbmc.eu>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu> <459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com> <6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net> <mailman.330.1701836673.3828.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net qhqBYZ50js9W9e9jXcXfRgu8aP87smSyWbJfAlpJ1UJEMiFCw=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:t3z/dbAP0OsllIGn7v/hqAapK8k= sha256:7z77Gl9fQdPrkVzMIDATIlGgAZ3jp8WHKAl1MTOkglU=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-89-generic (x86_64))
 by: Chris Green - Wed, 6 Dec 2023 09:32 UTC

Thomas Passin <list1@tompassin.net> 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 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 readability point of view it would be good to have a
> >> Python module with the values in it but using a Python program to
> >> write/update a Python module sounds a bit odd somehow.
> >>
> >> 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.
> >>
> >> Are there any Python modules aimed specifically at this sort of
> >> requirement?
> >>
> > Some kind of key/value store sounds like the correct solution. I
> > wouldn't go as far a database - that's overkill for a few calibration
> > values.
> >
> > I might suggest TOML, except that Python's tomllib (Python 3.11+) is
> > read-only!
> >
> > Personally, I'd go for lines of:
> >
> >     key1: value1
> >     key2: value2
> >
> > Simple to read, simple to write.
>
> Just go with an .ini file. Simple, well-supported by the standard
> library. And it gives you key/value pairs.
>
My requirement is *slightly* more complex than just key value pairs,
it has one level of hierarchy, e.g.:-

KEY1:
a: v1
c: v3
d: v4
KEY2:
a: v7
b: v5
d: v6

Different numbers of value pairs under each KEY.

--
Chris Green
·

Re: How/where to store calibration values - written by program A, read by program B

<hes54k-24m9.ln1@esprimo.zbmc.eu>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!rocksolid2!news.neodome.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A, read by program B
Date: Wed, 6 Dec 2023 09:45:21 +0000
Lines: 29
Message-ID: <hes54k-24m9.ln1@esprimo.zbmc.eu>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu> <87r0k05sw7.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net rQ8YqFbbKSqgwBAqDIGgFwlS2kwtW+kiXeYQeGdYQ/eIbXEro=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:d2Vmg7SlqkAC+tkQf15KNPoYw+8= sha256:2MZRgbZwfpNH1ik0yKexNu89V6hObkVB/IndZjY20uE=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-89-generic (x86_64))
 by: Chris Green - Wed, 6 Dec 2023 09:45 UTC

Paul Rubin <no.email@nospam.invalid> wrote:
> Chris Green <cl@isbd.net> 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, though its intention is files that are
> manually edited, rather than updated by a program.
>
> You can also read and dump a json file or pickle file. I prefer json to
> pickle for most purposes these days.
>
> I don't like YAML and I don't like the proliferation of markup formats
> of this type. So while I don't know exactly what TOML is, I figure it
> must be bad.
>
> I sometimes use ast.literal_eval though it is Python specific.
>
That's interesting, I'll add it to my armoury anyway. :-)

> Of course there is also sqlite but that is probably overkill.

It's what my current code uses but does feel a bit OTT and it isn't
particularly convenient to view when debugging.

--
Chris Green
·

Re: How/where to store calibration values - written by program A, read by program B

<files-20231206105506@ram.dialup.fu-berlin.de>

  copy mid

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

  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: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A, read by program B
Date: 6 Dec 2023 09:55:46 GMT
Organization: Stefan Ram
Lines: 14
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <files-20231206105506@ram.dialup.fu-berlin.de>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu> <459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com> <6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net> <mailman.330.1701836673.3828.python-list@python.org> <ilr54k-24m9.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 biBt4cJt6dQwMoAemV4k8wyd4wuefIWq9Nfq01hoD/z30Q
Cancel-Lock: sha1:K63INic0KnDzV0DnxSGhtFB7jq4= sha256:4+knBn4LOutCqczIoNU6GykKXg0HHSj/lD++uXg+2dw=
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 - Wed, 6 Dec 2023 09:55 UTC

Chris Green <cl@isbd.net> writes:
> KEY1:
> a: v1
> c: v3
> d: v4
> KEY2:
> a: v7
> b: v5
> d: v6

That maps nicely to two directories with three files
(under an application-specific configuration directory).

Re: How/where to store calibration values - written by program A, read by program B

<tks54k-24m9.ln1@esprimo.zbmc.eu>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: cl@isbd.net (Chris Green)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A, read by program B
Date: Wed, 6 Dec 2023 09:48:45 +0000
Lines: 6
Message-ID: <tks54k-24m9.ln1@esprimo.zbmc.eu>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu> <fa46a76f-4600-4a62-9ad6-9f20ca02b5cf@DancesWithMice.info> <3563e673-112d-4cfc-b30a-c5394d6c35ff@DancesWithMice.info> <mailman.329.1701810499.3828.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 9cS6K2B9u/iv1n6XXCHnpQ0R4m2iI8ELzmKWKll23AX1MLdrs=
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:XRJXZkx7xhcvYchtYomzTjky3Iw= sha256:j76IvBwqCQPCFkOdBpHrdIE2v7onjH0q3r1Sk6wORMU=
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-89-generic (x86_64))
 by: Chris Green - Wed, 6 Dec 2023 09:48 UTC

Thank you everyone for all the suggestions, I now have several
possibilities to follow up. :-)

--
Chris Green
·

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.samoylyk.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4RzWzUUiLuE@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 05:40:50 -0500
Lines: 27
Message-ID: <mailman.331.1701859261.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu> <ZXBPsvZEuFccK4gB@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de r6qDE0cariKxd3d2ATAsnQAaoCDDpkF1hYE6tICNiNgA==
Cancel-Lock: sha1:uTgbcPcJPlb0RAPtSuAPaRVaBV4= sha256:s92oXFf49Bd1sDHHwRk04qvKyJb51xAN4c4okEx0CBg=
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.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=potatochowder.com header.i=@potatochowder.com
header.b=ZlKjnpPW; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.040
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'library.': 0.05;
'received:78': 0.09; 'subject:, \n ': 0.09;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'key.': 0.16; 'received:136.243': 0.16; 'received:172.58':
0.16; 'received:www458.your-server.de': 0.16; 'received:your-
server.de': 0.16; 'subject:program': 0.16; 'subject:values': 0.16;
'wrote:': 0.16; 'to:addr:python-list': 0.20; 'subject:How': 0.23;
'url:wiki': 0.23; 'received:de': 0.23; 'chris': 0.28; 'python-
list': 0.32; 'received:136': 0.32; 'simple,': 0.32; 'header:In-
Reply-To:1': 0.34; 'complex': 0.35; 'files': 0.36; 'gives': 0.62;
'key': 0.64; 'requirement': 0.64; 'numbers': 0.67; 'subject:read':
0.69; 'url-ip:208.80/16': 0.70; 'url:wikipedia': 0.70; 'url-
ip:208/8': 0.71; 'pairs': 0.84; 'subject:where': 0.84; 'green':
0.96
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=potatochowder.com; s=default2305; h=In-Reply-To:Content-Type:MIME-Version:
References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:
Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=CR9iEemB0I76/jpTSorRmBAdg0KCxGNaBkWWjQxGfDw=; b=ZlKjnpPWSIMiG/kwyGjKWomYWw
EG7AlPbIQRevxClhYz+9tUMQnpJJlbH2lQyg7n49owJVFXLMuQGlhLGkdRBw8lWZcZeEQa7WTl1RH
aAdEnRRcOgpTq7TAt/VmadJSG1cZ4wUzYc55hTNYiQo0f2rQI+96HOs0TchQr0uH/GY3nDGKOAkwk
LSWr0gHdmYEzSvvvsyEcC5/wvZPVcAGzGcs8D/h5WC6oFQuTh1ZNh8+OUXw+nkitGiwe1hyEL01sc
V9DAqiraES/6/NpkzLkRdn8mPoY8y9vLh0twjCaJEay8xR4GYHZ1BDrg1WnKzb9D8zhBzeL0pFL0b
JNRIpnmQ==;
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <ilr54k-24m9.ln1@esprimo.zbmc.eu>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.10/27115/Wed Dec 6 09:44:21 2023)
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: <ZXBPsvZEuFccK4gB@anomaly>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
 by: 2QdxY4RzWzUUiLuE@potatochowder.com - Wed, 6 Dec 2023 10:40 UTC

On 2023-12-06 at 09:32:02 +0000,
Chris Green via Python-list <python-list@python.org> wrote:

> Thomas Passin <list1@tompassin.net> wrote:

[...]

> > Just go with an .ini file. Simple, well-supported by the standard
> > library. And it gives you key/value pairs.
> >
> My requirement is *slightly* more complex than just key value pairs,
> it has one level of hierarchy, e.g.:-
>
> KEY1:
> a: v1
> c: v3
> d: v4
> KEY2:
> a: v7
> b: v5
> d: v6
>
> Different numbers of value pairs under each KEY.

INI files have sections.

See <https://en.wikipedia.org/wiki/INI_file#Sections>.

Re: How/where to store calibration values - written by program A, read by program B

<slrnun0lgq.hsj.dan@djph.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dan@djph.net (Dan Purgert)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 11:06:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <slrnun0lgq.hsj.dan@djph.net>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<files-20231206105506@ram.dialup.fu-berlin.de>
Injection-Date: Wed, 6 Dec 2023 11:06:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="73ba5a53c768c499b2fbab4a59f9bbb5";
logging-data="789583"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/l5HAWahKLRrs4KVURztG3P2HncpAhuE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:nv8Y6sRklDL9ff/p8iHPXtVF2dk=
 by: Dan Purgert - Wed, 6 Dec 2023 11:06 UTC

On 2023-12-06, Stefan Ram wrote:
> Chris Green <cl@isbd.net> writes:
>> KEY1:
>> a: v1
>> c: v3
>> d: v4
>> KEY2:
>> a: v7
>> b: v5
>> d: v6
>
> That maps nicely to two directories with three files
> (under an application-specific configuration directory).

Or an .ini file with two sections (although I don't think you can re-use
key-names in a single ini file)

--
|_|O|_|
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!fu-berlin.de!uni-berlin.de!not-for-mail
From: barry@barrys-emacs.org (Barry Scott)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 11:35:04 +0000
Lines: 42
Message-ID: <mailman.332.1701862528.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 3BslgAgpYeVG5rYFLocrNg6ueUXBUKzlSHRXYmWM2jqQ==
Cancel-Lock: sha1:1JVtzbRF6leWyVPDb6157wkMgRg= sha256:mreuPswd/EXYs0bKBaf5DeEh5ecQk0eOAtziRzSMEtM=
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.068
X-Spam-Evidence: '*H*': 0.87; '*S*': 0.01; 'debugging': 0.07; 'cc:addr
:python-list': 0.09; 'from:addr:barry': 0.09; 'json': 0.09;
'received:217.70': 0.09; 'received:217.70.178': 0.09;
'received:gandi.net': 0.09; 'received:mail.gandi.net': 0.09;
'subject:, \n ': 0.09; 'cc:no real name:2**0': 0.14; 'barry':
0.16; 'from:addr:barrys-emacs.org': 0.16; 'from:name:barry scott':
0.16; 'key.': 0.16; 'message-id:@barrys-emacs.org': 0.16;
'subject:program': 0.16; 'subject:values': 0.16; 'wrote:<span':
0.16; 'wrote:': 0.16; 'cc:addr:python.org': 0.20; 'subject:How':
0.23; 'cc:2**0': 0.25; 'chris': 0.28; 'email addr:python.org&gt;':
0.28; 'dec': 0.31; 'personally': 0.32; 'python-list': 0.32; '0);':
0.33; 'rgb(0,': 0.33; 'header:In-Reply-To:1': 0.34; 'complex':
0.35; 'errors': 0.36; 'use': 0.39; 'data.': 0.40; 'font-family:':
0.60; 'inline': 0.61; 'display:': 0.62; 'none;': 0.62; 'format':
0.62; 'days': 0.62; 'font-weight:': 0.62; '0px;': 0.63; 'key':
0.64; 'requirement': 0.64; 'text-indent:': 0.64; 'normal;': 0.66;
'numbers': 0.67; 'received:217': 0.67; 'skip:! 10': 0.67;
'subject:read': 0.69; 'float:': 0.74; 'skip:! 20': 0.81; 'email
name:&lt;python-list': 0.84; 'pairs': 0.84; 'subject:where': 0.84;
'400;': 0.89; '13px;': 0.91; 'green': 0.96
In-Reply-To: <ilr54k-24m9.ln1@esprimo.zbmc.eu>
X-Mailer: Apple Mail (2.3774.200.91.1.1)
X-GND-Sasl: barry@barrys-emacs.org
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
 by: Barry Scott - Wed, 6 Dec 2023 11:35 UTC

> On 6 Dec 2023, at 09:32, Chris Green via Python-list <python-list@python.org> wrote:
>
> My requirement is *slightly* more complex than just key value pairs,
> it has one level of hierarchy, e.g.:-
>
> KEY1:
> a: v1
> c: v3
> d: v4
> KEY2:
> a: v7
> b: v5
> d: v6
>
> Different numbers of value pairs under each KEY.

JSON will allow you to nest dictionaries.

{
'KEY1': {
'a': v1
'c': v3
'd': v4
}
'KEY2': {
'a': v7
'b': v5
'd': v6
}
}

Personally I would not use .ini style these days as the format does not include type of the data.

Also I would not use the ast.literal_eval as it makes debugging errors in the data harder.

Barry

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  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: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 07:23:51 -0500
Lines: 45
Message-ID: <mailman.333.1701884374.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de IytbgSk0CbzcP/2ZHxVkxQstvmNR3Z2rCE9sPPZ7knLQ==
Cancel-Lock: sha1:899HeibdocpCxPfdltb0/Sf860M= sha256:Xk5B2BzqEKxQVTFkDeJ1UM4dwMty2s0uzSecyzEsGXw=
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=iZDkZL+K;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.021
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'library.': 0.05;
"python's": 0.05; 'fact,': 0.09; 'json': 0.09;
'received:23.83.212': 0.09; 'received:elm.relay.mailchannels.net':
0.09; 'smaller': 0.09; 'subject:, \n ': 0.09; 'barry': 0.16;
'key.': 0.16; 'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'wrote:': 0.16; 'to:addr:python-list':
0.20; 'maybe': 0.22; 'lines': 0.23; 'subject:How': 0.23; "isn't":
0.27; 'chris': 0.28; 'fact': 0.28; 'header:User-Agent:1': 0.30;
'am,': 0.31; 'dec': 0.31; 'course.': 0.32; 'files,': 0.32;
'personally': 0.32; 'python-list': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; "wouldn't": 0.32; 'header
:In-Reply-To:1': 0.34; 'complex': 0.35; 'missing': 0.37; 'using':
0.37; 'least': 0.39; 'necessary': 0.39; 'use': 0.39; 'neither':
0.39; 'data.': 0.40; 'format': 0.62; 'here': 0.62; 'days': 0.62;
'browser': 0.64; 'key': 0.64; 'requirement': 0.64; 'your': 0.64;
'numbers': 0.67; 'header:Received:6': 0.67; 'received:64': 0.67;
'matter': 0.68; 'subject:read': 0.69; 'besides,': 0.84; 'pairs':
0.84; 'scott': 0.84; 'subject:where': 0.84; 'green': 0.96
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1701865432; a=rsa-sha256;
cv=none;
b=sUlPfm3f6BVKqFcXpiWOjIl3NcUw6RLDH1lC0OUXGZqLyGPOU8GrJZxgtC8/M8tgHSVcen
q2Danayo1dT17igARh1RKIvYtEHhYhcyLeKBZ/igeFSqf6S4ZzeRpZ+WoTYz8ZoQcwAoDP
zF3SOIQC/u309KzH3JU8nwUVt+RIZSNzEaQekhlZVjtx7Kxgnr8HjKKBcBh4vq0zdHUtMd
V8FOnGggXWdB6OaXEp07pXBpodUSGd/OiaKqiL1yJk4CYKmz/FpVyShyYPMKWg+JPV/+nN
Ib07CzT4sx83Z66oxCvGQTwHZMYmcU3DAihHgAJeUc+UGHD0V9kMSi3wYekb0g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1701865432;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=mqZmo4KyXTb36h1/gVXPz1ClOrGNBb7sHfOr4JAZNYE=;
b=GHt5D6U5mkmv8l/HSloCSRwbf7ADYIbkFjw/GUO2AiopWRjWmhNGz8g5qMxmW0Sw6qYfOZ
8tUxWsXrQG63/iy6r9VgEYWSeuMWjlj1IQPR0mehT7vDbaGS+SailuIgrnCvb0+Y30wred
ICgh4wcBAspsnD1nnhkOPv7aCu7yGPXbccGnNC8VH9T8sVxDO65ZVEqGAlTuwETC1aqWwG
amVpCGlsaI7voq+8qbEZKOTRV6TUtkiRlMprozM/bLAoFvGW6xInhOQZp49v2DBumx/owV
6gBjnSH8aA7u9Ejk3/RjkEL98HQrv7LaKrUyFc+YnKPXNvfoZRPsIA5GlK7CUA==
ARC-Authentication-Results: i=1; rspamd-696ff67dc8-wv6q9;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Whimsical-Illustrious: 60a242fb345b3b5f_1701865433092_2118892328
X-MC-Loop-Signature: 1701865433092:1428852903
X-MC-Ingress-Time: 1701865433092
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1701865432;
bh=mqZmo4KyXTb36h1/gVXPz1ClOrGNBb7sHfOr4JAZNYE=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=iZDkZL+K0eTi0dSWruM63zcqtXSodvY+jtphINidVd6sxcw6HLrL1BgfTB9EExvkU
3EP5e7AT6B47++ruPjr1Wh0W6R8OulSfWEPvxbtP8Qn+ohZZEC7uhxGxwxmJtHDf5o
KWMkrUoZQ9i6DfmmGt39ux5cj81GhIk+MRtwaV1caLJ8+36TguZOOBWfBg10VWLVAw
qUVOYr0LIql+nk4gDw/Uavm7wm4hVq3E8S8G0zfUfHNQ07yaI098iLAKqYNDTSNgBm
45b9cRXMsNL4ctURhWaazJ9rl3DB1qLikJMy1lhs+Ph9Th6zwtFNByTMHo9kHsb3tR
MYoC0lRjQbAaw==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
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: <dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
 by: Thomas Passin - Wed, 6 Dec 2023 12:23 UTC

On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
>
>
>> On 6 Dec 2023, at 09:32, Chris Green via Python-list <python-list@python.org> wrote:
>>
>> My requirement is *slightly* more complex than just key value pairs,
>> it has one level of hierarchy, e.g.:-
>>
>> KEY1:
>> a: v1
>> c: v3
>> d: v4
>> KEY2:
>> a: v7
>> b: v5
>> d: v6
>>
>> Different numbers of value pairs under each KEY.
>
> JSON will allow you to nest dictionaries.
>
> {
> 'KEY1': {
> 'a': v1
> 'c': v3
> 'd': v4
> }
> 'KEY2': {
> 'a': v7
> 'b': v5
> 'd': v6
> }
> }
>
> Personally I would not use .ini style these days as the format does not include type of the data.

Neither does JSON. Besides, JSON is more complicated than necessary
here - in fact, your example isn't even legal JSON since lines are
missing commas.

Fun fact - for at least some, maybe most, JSON files, using eval() on
them is hugely faster than using Python's standard JSON library. I
learned this when I wanted to ingest a large browser bookmarks JSON
file. It wouldn't matter for a much smaller file, of course.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 18:12:20 +0000
Lines: 47
Message-ID: <mailman.334.1701886529.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de e4W6q9eAVohY6bMgn0WF8gV9hKdd+pF+cImRSrkeCn2g==
Cancel-Lock: sha1:lQXJUCOnUB+M/Dsb60LullghB3k= sha256:Tnl2GtlkHeO1A4YWCNyMgGeBBFLGwSVQQ5m0dS1pFeU=
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=aUHvsJzw;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.025
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'library.': 0.05;
"python's": 0.05; 'fact,': 0.09; 'from:addr:python': 0.09; 'json':
0.09; 'received:192.168.1.64': 0.09; 'smaller': 0.09; 'subject:,
\n ': 0.09; 'barry': 0.16; 'from:addr:mrabarnett.plus.com': 0.16;
'from:name:mrab': 0.16; 'key.': 0.16; 'message-
id:@mrabarnett.plus.com': 0.16; 'received:plus.net': 0.16;
'subject:program': 0.16; 'subject:values': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'maybe': 0.22; 'lines': 0.23;
'subject:How': 0.23; "isn't": 0.27; '>>>': 0.28; 'chris': 0.28;
'fact': 0.28; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'dec':
0.31; 'course.': 0.32; 'files,': 0.32; 'personally': 0.32;
'python-list': 0.32; "wouldn't": 0.32; 'received:192.168.1': 0.32;
'header:In-Reply-To:1': 0.34; 'complex': 0.35; 'missing': 0.37;
'using': 0.37; 'received:192.168': 0.37; 'least': 0.39;
'necessary': 0.39; 'use': 0.39; 'neither': 0.39; 'data.': 0.40;
'format': 0.62; 'received:212': 0.62; 'here': 0.62; 'days': 0.62;
'browser': 0.64; 'key': 0.64; 'requirement': 0.64; 'your': 0.64;
'numbers': 0.67; 'matter': 0.68; 'safer': 0.69; 'subject:read':
0.69; 'besides,': 0.84; 'pairs': 0.84; 'scott': 0.84;
'subject:where': 0.84; 'green': 0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1701886342; bh=iLPkc4T8qQHU/z8fq7T/OzyQ7tuDUGKojnX7Pz/6CEk=;
h=Date:Subject:To:References:From:In-Reply-To;
b=aUHvsJzwf0bwXhHFHPn3vsZo65ejKLJJobGsfW+bC1GMR6Fn7VB3Vb5CyKZ13LyNN
ZqSxDLZLcAJ5Ekqy9PIKLAg8YBXbKymZ9EIYuywg+mdSn08qO3fqNDV37bp+kikE1H
cXIIdtFVg7di1uQKEv+j50NiQ//WJ5iHOZbX23SoWXXKUo+bZEvKYcrKnVl1nco/pU
Yquh5H8qziUYWhXyikA1qy29bQ9mvsWD1OfLIT7Oes7L8aJGkFfqOPPOsW/We0ltI5
oBH9+C4KyFCq4ls7XhJAaON0kaeF1/+YRwxzQuuSuhkoZmkewSU+wtrH+GDr3Jr7YS
gcA1eUx6Ux7Hg==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=EZXb/dqC c=1 sm=1 tr=0 ts=6570b986
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=Dt3Yqlpji5OrmdsloawA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
X-CMAE-Envelope: MS4xfPrqDoeUL7/d+l9psv01tkM4JNmF9gWlg1vzQ1B166mK+uAe/hMmKXNtb9DBLMnelw75O/2oxQwDoUtEpusFEdP+v9OqSLmzlEh3N5q/Cs28jzORB6Ry
K6j/N4ouJ3MC2UlUL4B4PXgqTiW+WQsseK2pwoyDWhK2sfTu6l3PZA5e9LdE3uDm5fhBBd2jLQv0UWniPLrOy5feVRndiQK2tDE=
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: <a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
 by: MRAB - Wed, 6 Dec 2023 18:12 UTC

On 2023-12-06 12:23, Thomas Passin via Python-list wrote:
> On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
>>
>>
>>> On 6 Dec 2023, at 09:32, Chris Green via Python-list <python-list@python.org> wrote:
>>>
>>> My requirement is *slightly* more complex than just key value pairs,
>>> it has one level of hierarchy, e.g.:-
>>>
>>> KEY1:
>>> a: v1
>>> c: v3
>>> d: v4
>>> KEY2:
>>> a: v7
>>> b: v5
>>> d: v6
>>>
>>> Different numbers of value pairs under each KEY.
>>
>> JSON will allow you to nest dictionaries.
>>
>> {
>> 'KEY1': {
>> 'a': v1
>> 'c': v3
>> 'd': v4
>> }
>> 'KEY2': {
>> 'a': v7
>> 'b': v5
>> 'd': v6
>> }
>> }
>>
>> Personally I would not use .ini style these days as the format does not include type of the data.
>
> Neither does JSON. Besides, JSON is more complicated than necessary
> here - in fact, your example isn't even legal JSON since lines are
> missing commas.
>
> Fun fact - for at least some, maybe most, JSON files, using eval() on
> them is hugely faster than using Python's standard JSON library. I
> learned this when I wanted to ingest a large browser bookmarks JSON
> file. It wouldn't matter for a much smaller file, of course.
>
It would be safer if you used literal_eval.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Thu, 7 Dec 2023 09:11:55 +1300
Organization: DWM
Lines: 60
Message-ID: <mailman.335.1701893524.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de FLTnNcWRvjwD5pFKE6vutgVWn39xMz4mwQVFLfHjXpFw==
Cancel-Lock: sha1:JUpZIw+Ew9a+nZ2LfC4dwtELJ3s= sha256:X5V4yMBTOQOfuL/4fpLMdUu1OinXi21h4o5DAinI2O8=
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=Rx4Jwl5O; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.042
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; "python's": 0.05; '=dn':
0.09; 'fact,': 0.09; 'from:addr:danceswithmice.info': 0.09;
'from:addr:pythonlist': 0.09; 'json': 0.09; 'smaller': 0.09;
'subject:, \n ': 0.09; '>>>>': 0.16; 'barry': 0.16; 'key.': 0.16;
'message-id:@DancesWithMice.info': 0.16; 'received:51.254': 0.16;
'received:51.254.211': 0.16; 'received:51.254.211.219': 0.16;
'received:cloud': 0.16; 'received:rangi.cloud': 0.16;
'subject:program': 0.16; 'subject:values': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'maybe': 0.22; 'lines': 0.23;
'subject:How': 0.23; "isn't": 0.27; '>>>': 0.28; 'chris': 0.28;
'fact': 0.28; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'dec':
0.31; 'header:Organization:1': 0.31; 'course.': 0.32; 'files,':
0.32; 'personally': 0.32; 'python-list': 0.32; "wouldn't": 0.32;
'received:192.168.1': 0.32; 'header:In-Reply-To:1': 0.34;
'complex': 0.35; 'missing': 0.37; 'using': 0.37;
'received:192.168': 0.37; 'least': 0.39; 'necessary': 0.39; 'use':
0.39; 'neither': 0.39; 'still': 0.40; 'data.': 0.40; 'skip:\xc2
10': 0.62; 'format': 0.62; 'here': 0.62; 'days': 0.62; 'browser':
0.64; 'key': 0.64; 'received:51': 0.64; 'requirement': 0.64;
'your': 0.64; 'numbers': 0.67; 'matter': 0.68; 'safer': 0.69;
'subject:read': 0.69; 'little': 0.73; '8bit%:100': 0.76;
'besides,': 0.84; 'pairs': 0.84; 'scott': 0.84; 'subject:where':
0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'green': 0.96
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 6053A7113
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1701893522;
bh=YQmuq0tgYgCy2sy1lOZSWLqgh/uMxkWaIvp9iSzk5bg=;
h=Date:From:Subject:To:References:In-Reply-To:From;
b=Rx4Jwl5O2GZ5uX1FW9vXpjnjH6u3x9zZAFXvxkvhVhjw65SEImCtAKjugtQpAFMiY
5ZOTbfKHdZzAxMvCAWG2+544lLsdLbZraGALl9Gihw3ckie+qzPHdllw/aThmqRvTt
6heBnYHFyDNETV6cmF0UcH1vOyGNPM9aQyrGFpe9arEDu6geYkXnW5rJ12ObwQ41by
Yii/CT56UMd3AUd6xBEOga6DcOXwtMVPKYaiRI89KNCJJUUiCWUvS7iOh7U+XP1Oj0
gb8pQxPRTyTWM37ex3Ord/sz27UiaitScpvbfoYU69dyuPLJck8EkLQcEnQU3dDAI7
z8NUA4NL/ywiw==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
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: <599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
 by: dn - Wed, 6 Dec 2023 20:11 UTC

On 7/12/23 07:12, MRAB via Python-list wrote:
> On 2023-12-06 12:23, Thomas Passin via Python-list wrote:
>> On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
>>>
>>>
>>>> On 6 Dec 2023, at 09:32, Chris Green via Python-list
>>>> <python-list@python.org> wrote:
>>>>
>>>> My requirement is *slightly* more complex than just key value pairs,
>>>> it has one level of hierarchy, e.g.:-
>>>>
>>>>     KEY1:
>>>>       a: v1
>>>>       c: v3
>>>>       d: v4
>>>>     KEY2:
>>>>       a: v7
>>>>       b: v5
>>>>       d: v6
>>>>
>>>> Different numbers of value pairs under each KEY.
>>>
>>> JSON will allow you to nest dictionaries.
>>>
>>> {
>>>      'KEY1': {
>>>          'a': v1
>>>          'c': v3
>>>          'd': v4
>>>      }
>>>      'KEY2': {
>>>           'a': v7
>>>           'b': v5
>>>           'd': v6
>>>      }
>>> }
>>>
>>> Personally I would not use .ini style these days as the format does
>>> not include type of the data.
>>
>> Neither does JSON.  Besides, JSON is more complicated than necessary
>> here - in fact, your example isn't even legal JSON since lines are
>> missing commas.
>>
>> Fun fact - for at least some, maybe most, JSON files, using eval() on
>> them is hugely faster than using Python's standard JSON library.  I
>> learned this when I wanted to ingest a large browser bookmarks JSON
>> file. It wouldn't matter for a much smaller file, of course.
>>
> It would be safer if you used literal_eval.

Ah, memories of Python2...

Does this little hack still work?

What about True/False cf true/false?

--
Regards,
=dn

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  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: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 20:32:44 +0000
Lines: 62
Message-ID: <mailman.336.1701894768.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de LnJAikJNibd1nqY4RSYcxQkLc4zKUOlualMg7hWZMJow==
Cancel-Lock: sha1:CCUKArQTqHCUZAdBSDNNAWexr58= sha256:qZgB/BvanQykop+aTEtT5ktt+Dc1t4eTo52TemKaWXY=
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=G6L7Lv6c;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.057
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; "python's": 0.05; 'fact,':
0.09; 'from:addr:python': 0.09; 'json': 0.09;
'received:192.168.1.64': 0.09; 'smaller': 0.09; 'subject:, \n ':
0.09; '>>>>': 0.16; '>>>>>': 0.16; 'barry': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'key.': 0.16; 'message-id:@mrabarnett.plus.com': 0.16;
'received:plus.net': 0.16; 'strings,': 0.16; 'subject:program':
0.16; 'subject:values': 0.16; 'wrote:': 0.16; 'to:addr:python-
list': 0.20; 'maybe': 0.22; 'lines': 0.23; 'subject:How': 0.23;
"isn't": 0.27; '>>>': 0.28; 'chris': 0.28; 'fact': 0.28; 'header
:User-Agent:1': 0.30; 'am,': 0.31; 'dec': 0.31; 'course.': 0.32;
'files,': 0.32; 'personally': 0.32; 'python-list': 0.32;
"wouldn't": 0.32; 'received:192.168.1': 0.32; 'header:In-Reply-
To:1': 0.34; 'complex': 0.35; 'lists': 0.37; 'missing': 0.37;
'using': 0.37; "it's": 0.37; 'received:192.168': 0.37; 'least':
0.39; 'necessary': 0.39; 'use': 0.39; 'neither': 0.39; 'still':
0.40; 'data.': 0.40; 'skip:\xc2 10': 0.62; 'format': 0.62;
'received:212': 0.62; 'here': 0.62; 'days': 0.62; 'browser': 0.64;
'key': 0.64; 'requirement': 0.64; 'your': 0.64; 'numbers': 0.67;
'matter': 0.68; 'safer': 0.69; 'subject:read': 0.69; 'little':
0.73; '8bit%:100': 0.76; 'besides,': 0.84; 'pairs': 0.84; 'scott':
0.84; 'subject:where': 0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0':
0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'green':
0.96
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1701894766; bh=XKmG2XLaekqJqRcP7a8T3F5zxL5nNIZOIVsh5ntUJzQ=;
h=Date:Subject:To:References:From:In-Reply-To;
b=G6L7Lv6cNNyygfZQb+HXZYe0pXKkgAaCwJo+YhTphR2kfuqJcRklDLS/uL5FdJbx8
bISeZRKYzN1Qoa7rxjVcHO0PIjAH6OF7Pb7t05vPK2K1+K85aNhiYuh8j8oEN5H7M5
8fDnhfHiqajTs2VAO3WM4z+xfvxRn7m+3FfOIuI7S8DZFykmnLEMJHz71IFWXPOP+M
s7jZQtxPlkxPy7kziKOhbTQ7RHpZS+aSaMmFg/yAkw0lOhAY2uAcDbysWY820ZqBbg
NOieZrCLr1Jate2grGclih4OpQ2n+FlzbezL82Zdwm5GvaPYy2dzi+6z+xviFEbqFo
UFUcMZBy3XRiQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=EZXb/dqC c=1 sm=1 tr=0 ts=6570da6e
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=IPcl6PseWOBTTlGXEh4A:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
X-CMAE-Envelope: MS4xfBRA0QLYp0US7jaY1Bffmmt7FvKmyYu4jxzkhrTqJgz2ZyMTzv/dPfL8mVF1gAdeQCAGY5SyoUxSrH92S98EpbqExAj2RHge+TmPPeDjvYosNrHKq4X9
8tnbAwrntgMqzugumY9oBCXDlmwRF6n4ZoJpQWG9uqKu7VeVijUmUWMWDTesg3cw0PaMHXvlhe1yD0IbJ7C39cCWO5d6Vg63tj8=
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: <2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
 by: MRAB - Wed, 6 Dec 2023 20:32 UTC

On 2023-12-06 20:11, dn via Python-list wrote:
> On 7/12/23 07:12, MRAB via Python-list wrote:
>> On 2023-12-06 12:23, Thomas Passin via Python-list wrote:
>>> On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
>>>>
>>>>
>>>>> On 6 Dec 2023, at 09:32, Chris Green via Python-list
>>>>> <python-list@python.org> wrote:
>>>>>
>>>>> My requirement is *slightly* more complex than just key value pairs,
>>>>> it has one level of hierarchy, e.g.:-
>>>>>
>>>>>     KEY1:
>>>>>       a: v1
>>>>>       c: v3
>>>>>       d: v4
>>>>>     KEY2:
>>>>>       a: v7
>>>>>       b: v5
>>>>>       d: v6
>>>>>
>>>>> Different numbers of value pairs under each KEY.
>>>>
>>>> JSON will allow you to nest dictionaries.
>>>>
>>>> {
>>>>      'KEY1': {
>>>>          'a': v1
>>>>          'c': v3
>>>>          'd': v4
>>>>      }
>>>>      'KEY2': {
>>>>           'a': v7
>>>>           'b': v5
>>>>           'd': v6
>>>>      }
>>>> }
>>>>
>>>> Personally I would not use .ini style these days as the format does
>>>> not include type of the data.
>>>
>>> Neither does JSON.  Besides, JSON is more complicated than necessary
>>> here - in fact, your example isn't even legal JSON since lines are
>>> missing commas.
>>>
>>> Fun fact - for at least some, maybe most, JSON files, using eval() on
>>> them is hugely faster than using Python's standard JSON library.  I
>>> learned this when I wanted to ingest a large browser bookmarks JSON
>>> file. It wouldn't matter for a much smaller file, of course.
>>>
>> It would be safer if you used literal_eval.
>
> Ah, memories of Python2...
>
> Does this little hack still work?
>
> What about True/False cf true/false?
>
Nope, nor None cf null.

If it's numbers, strings, lists and dicts, it works.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  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: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Wed, 6 Dec 2023 15:31:44 -0500
Lines: 54
Message-ID: <mailman.337.1701906875.3828.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<ac378c3c-1f95-4b4d-8492-3fc583b53d01@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de N+lh5CaKY6gNNxxNvDkgUAMuFeVi7IpMSJxaCfaOBgvA==
Cancel-Lock: sha1:lA8kZJWwZHKIp09lyrLxw3ofpSk= sha256:tSCioSnhu2rDf74Kae2l4nbODm6uOOddlIWeLO9Vul4=
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=M8eicvNp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.063
X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; "python's": 0.05; 'fact,':
0.09; 'json': 0.09; 'received:23.83.212': 0.09;
'received:elm.relay.mailchannels.net': 0.09; 'smaller': 0.09;
'subject:, \n ': 0.09; '>>>>': 0.16; 'barry': 0.16; 'key.': 0.16;
'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'subject:program': 0.16;
'subject:values': 0.16; 'wrote:': 0.16; 'pm,': 0.19; 'to:addr
:python-list': 0.20; 'maybe': 0.22; 'lines': 0.23; 'subject:How':
0.23; "isn't": 0.27; '>>>': 0.28; 'chris': 0.28; 'fact': 0.28;
'header:User-Agent:1': 0.30; 'am,': 0.31; 'dec': 0.31; 'course.':
0.32; 'files,': 0.32; 'personally': 0.32; 'python-list': 0.32;
'received:10.0': 0.32; 'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; "wouldn't": 0.32; 'header
:In-Reply-To:1': 0.34; 'complex': 0.35; 'missing': 0.37; 'using':
0.37; 'least': 0.39; 'necessary': 0.39; 'safe': 0.39; 'use': 0.39;
'neither': 0.39; 'data.': 0.40; 'should': 0.40; 'skip:\xc2 10':
0.62; 'format': 0.62; 'here': 0.62; 'days': 0.62; 'browser': 0.64;
'key': 0.64; 'requirement': 0.64; 'your': 0.64; 'his': 0.65;
'numbers': 0.67; 'header:Received:6': 0.67; 'received:64': 0.67;
'matter': 0.68; 'safer': 0.69; 'subject:read': 0.69; '8bit%:100':
0.76; 'besides,': 0.84; 'pairs': 0.84; 'scott': 0.84;
'subject:where': 0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'green': 0.96
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1701894705; a=rsa-sha256;
cv=none;
b=TzHff9Vv+sXgcNCTZ089EtE/sa9UEBWGeSlvUvqYd+bxRcX/OlJy3sqNdk6u1CD6k/yCS3
49CGI6uvzGDN2DJ7/laiTbQyJj6I5k2TcKiURsmteiYzlDPZtfbe3RUv9XgtmksbJjPD2D
7AC1DrWwjWII7KZ4LPYOF1RvD96R2FUjhrcCWJSEmSi6kx8poAhj4toP8eSWadKdiqsQmc
ntAY3USdaUy+s5NV7ZAr46j9MVEla2wchXAZVxMx3PmwfvaMP4d3OTlFvjf/f2SxqasleM
2DDLgouu9Ry7su6cWmo9XJTSb5xxBAtxGQe4SsQm+seZhqAgbdbMRS5SzsNwtA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1701894705;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=YcBgGR7uZC+rsSysZyP39YAEJ0oB+VSPSgMPcsX32Jo=;
b=pjcqmYUwhIXR4nRbWPwQeduISFZGW0CB2+AL0+wtPfC2P6UKFSMRYQ8zYSQ+DbN8yUZH+5
CZj+7mB6oJ7SwLHz5Jfffdb6mhWuYhD7ET9JLeCVqlYv9EZjUQdY0RMsDccOwFmkq68xHJ
Ik56CwAZbNHtdmzm+Oex9m9gH5Pvvr45VeQzGBLRu0Ek2p8ya+tuWEJstUcOARk017+mhl
uleNBKTXDtgyeCrBHalRHyIlfXlyndMkaQ6qdC2DmI85xMU/JqJRrnE0ZisLZV5HYcqO1f
cAvOPDCzROD/oKsfVi1I6uywUp/11QXWEiKAvVmAHl4Mc1RLJhxHCBihIKNpPw==
ARC-Authentication-Results: i=1; rspamd-696ff67dc8-nhsch;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Whispering-Blushing: 1b57ea5330755075_1701894705473_3056335645
X-MC-Loop-Signature: 1701894705473:320659381
X-MC-Ingress-Time: 1701894705473
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1701894705;
bh=YcBgGR7uZC+rsSysZyP39YAEJ0oB+VSPSgMPcsX32Jo=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=M8eicvNptO5PhZf9UnD/WzQHxE2mmyGI9Sgf0nMZ7mxgELXahjjjMuGNE4M+5JwPZ
14s4FqdFst7s9QXc/HfyxxXHIMvw/9qOxM6speEzW+Clbdwt6W0lyRfXKnqff6CVPD
FTWusBENx/tEF417nAppL7B3/4nDgpWBkv+prQEuyJyxSCXhKdiNx3xSh1vT3N/Wad
PYimdgbnc9inahhgocYZ1apnQ4beQOon0cVj5VXZ2qw7TXhx0qxZMFenTz/J97IozI
x9xJjBmZBvW9P0K8UCMp8a8EEtXxzRhHag7pjpsSeO+se496pY3L4GrJY5JlkRIusk
FmUllGKmf/Now==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
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: <ac378c3c-1f95-4b4d-8492-3fc583b53d01@tompassin.net>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
 by: Thomas Passin - Wed, 6 Dec 2023 20:31 UTC

On 12/6/2023 1:12 PM, MRAB via Python-list wrote:
> On 2023-12-06 12:23, Thomas Passin via Python-list wrote:
>> On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
>>>
>>>
>>>> On 6 Dec 2023, at 09:32, Chris Green via Python-list
>>>> <python-list@python.org> wrote:
>>>>
>>>> My requirement is *slightly* more complex than just key value pairs,
>>>> it has one level of hierarchy, e.g.:-
>>>>
>>>>     KEY1:
>>>>       a: v1
>>>>       c: v3
>>>>       d: v4
>>>>     KEY2:
>>>>       a: v7
>>>>       b: v5
>>>>       d: v6
>>>>
>>>> Different numbers of value pairs under each KEY.
>>>
>>> JSON will allow you to nest dictionaries.
>>>
>>> {
>>>      'KEY1': {
>>>          'a': v1
>>>          'c': v3
>>>          'd': v4
>>>      }
>>>      'KEY2': {
>>>           'a': v7
>>>           'b': v5
>>>           'd': v6
>>>      }
>>> }
>>>
>>> Personally I would not use .ini style these days as the format does
>>> not include type of the data.
>>
>> Neither does JSON.  Besides, JSON is more complicated than necessary
>> here - in fact, your example isn't even legal JSON since lines are
>> missing commas.
>>
>> Fun fact - for at least some, maybe most, JSON files, using eval() on
>> them is hugely faster than using Python's standard JSON library.  I
>> learned this when I wanted to ingest a large browser bookmarks JSON
>> file. It wouldn't matter for a much smaller file, of course.
>>
> It would be safer if you used literal_eval.

He's going to be writing his own calibration data files, though, so it
should be safe for his purposes.

Re: How/where to store calibration values - written by program A, read by program B

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: hjp-python@hjp.at (Peter J. Holzer)
Newsgroups: comp.lang.python
Subject: Re: How/where to store calibration values - written by program A,
read by program B
Date: Sat, 9 Dec 2023 10:59:24 +0100
Lines: 47
Message-ID: <mailman.0.1702116363.2892.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<20231209095924.ba5j3yxcx36kvw7j@hjp.at>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="pgmdsq73br3b5hnu"
X-Trace: news.uni-berlin.de NopXkGYfCpb9c21aNQy+3g6Mk+ZeHAs1rd8sql42t+lw==
Cancel-Lock: sha1:jJ81Xe2CIzxTOzSOWWAOkPjDRBw= sha256:4zmLrW2mPAWgKaWtDpUw6du7zJYLCmYWrRTjR7vP0kU=
Return-Path: <hjp-python@hjp.at>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'content-
type:multipart/signed': 0.05; 'content-type:application/pgp-
signature': 0.09; 'filename:fname piece:asc': 0.09;
'filename:fname piece:signature': 0.09;
'filename:fname:signature.asc': 0.09; 'json': 0.09; 'subject:, \n
': 0.09; '"creative': 0.16; '__/': 0.16; 'barry': 0.16;
'challenge!"': 0.16; 'from:addr:hjp-python': 0.16;
'from:addr:hjp.at': 0.16; 'from:name:peter j. holzer': 0.16;
'hjp@hjp.at': 0.16; 'holzer': 0.16; 'reality.': 0.16; 'stross,':
0.16; 'subject:program': 0.16; 'subject:values': 0.16; 'url-
ip:212.17.106/24': 0.16; 'url-ip:212.17/16': 0.16; 'url:hjp':
0.16; '|_|_)': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20;
'subject:How': 0.23; 'anything': 0.25; 'sense': 0.28; 'am,': 0.31;
'else,': 0.32; 'personally': 0.32; 'python-list': 0.32; 'header
:In-Reply-To:1': 0.34; 'those': 0.36; 'two': 0.39; 'use': 0.39;
'neither': 0.39; 'data.': 0.40; 'format': 0.62; 'received:212':
0.62; 'days': 0.62; 'between': 0.63; 'number,': 0.64; 'your':
0.64; 'received:userid': 0.66; 'types': 0.67; 'subject:read':
0.69; 'url-ip:212/8': 0.69; 'null)': 0.84; 'received:at': 0.84;
'scott': 0.84; 'subject:where': 0.84
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
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: <20231209095924.ba5j3yxcx36kvw7j@hjp.at>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
 by: Peter J. Holzer - Sat, 9 Dec 2023 09:59 UTC
Attachments: signature.asc (application/pgp-signature)

On 2023-12-06 07:23:51 -0500, Thomas Passin via Python-list wrote:
> On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:
> > Personally I would not use .ini style these days as the format does not include type of the data.
>
> Neither does JSON.

Well, it distinguishes between some primitive types (string, number,
boolean, null) and provides two container types (dict/object,
list/array). As long as those types are sufficient, JSON includes them.
If you need anything else, you're on your own.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

Attachments: signature.asc (application/pgp-signature)
A problem with str VS int.

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Gronicus@SGA.Ninja (Steve GS)
Newsgroups: comp.lang.python
Subject: A problem with str VS int.
Date: Sat, 9 Dec 2023 21:42:06 -0500
Lines: 21
Message-ID: <mailman.1.1702178153.2892.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
<000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de WK1bnlwbhBbrllni6TeoMAz4l5cKGYCGK51jB1ctMxRg==
Cancel-Lock: sha1:R9bMW/UbDEciJfgGDfbiPqWF2oo= sha256:cFc5RNtS/0gBlTpr8Cr5zhqAZ4BJiKhqSrKGA2Qr2BU=
Return-Path: <Gronicus@SGA.Ninja>
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=sga.ninja header.i=@sga.ninja header.b=DMWskpkS;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:problem': 0.03;
'variable': 0.05; 'sensor': 0.07; 'comparison': 0.09; 'else:':
0.09; 'fails': 0.09; 'int': 0.09; 'expected.': 0.16;
'from:addr:gronicus': 0.16; 'from:addr:sga.ninja': 0.16; 'message-
id:@SGA.Ninja': 0.16; 'received:floathosting.com': 0.16;
'received:mars.floathosting.com': 0.16; 'to:addr:python-list':
0.20; 'input': 0.21; 'code': 0.23; 'else': 0.27; 'but': 0.32;
'header:In-Reply-To:1': 0.34; 'two': 0.39; 'valid': 0.39; 'steve':
0.39; 'number,': 0.64; 'converted': 0.84; 'you...': 0.84
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sga.ninja;
s=default;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:
Date:Subject:In-Reply-To:References:To:From:Sender:Reply-To:Cc:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=9WUsQkMmz05AGFtCh4eA2wLmAbcR2eBVfa95JdjOAZc=; b=DMWskpkSDv2b7eMip2sLEzha4X
f/9en9j2J1u51aew1CUjdpdlGTZRxZKkXXMJVQPWKXJXBSjg4UOg0NOTAude6mEH3vDAKVRBaPCiQ
VhTPC/uCItVwOrJREeht5S40EuWvVaILxyjd8jG/DPRstFD5WloD0nvM/r3OX2yxY81Th6+GcgSQE
H87ACNOPcpRCxDVP5FoFi8Ragwh9WKY3Dvr94S8hcsjR81BShkvE/trUEXjG7tVuZDEVFTGL5jFOj
HzWDeNQ7BKvRCdlDjQrkjGblvHrmTtriPy1kNOHYRXl65IFmsguVCehAfqQ8Kl2dtaNl0czNnkPmj
9Gxw+FJA==;
In-Reply-To: <2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AdorD5k+wAWVrqeeR0KmMMy8feEdXw==
Content-Language: en-us
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - mars.floathosting.com
X-AntiAbuse: Original Domain - python.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - SGA.Ninja
X-Get-Message-Sender-Via: mars.floathosting.com: authenticated_id:
gronicus@sga.ninja
X-Authenticated-Sender: mars.floathosting.com: gronicus@sga.ninja
X-Source:
X-Source-Args:
X-Source-Dir:
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: <000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
 by: Steve GS - Sun, 10 Dec 2023 02:42 UTC

If I enter a one-digit input or a three-digit number, the code works but if I enter a two digit number, the if statement fails and the else condition prevails.

tsReading = input(" Enter the " + Brand + " test strip reading: ")
if tsReading == "": tsReading = "0"
print(tsReading)
if ((tsReading < "400") and (tsReading >= "0")):
tsDose = GetDose(sReading)
print(tsReading + "-" + tsDose)
ValueFailed = False
else:
print("Enter valid sensor test strip Reading.")

I converted the variable to int along with the if statement comparison and it works as expected.
See if it fails for you...

Steve

RE: A problem with str VS int.

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

  copy mid

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

  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: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: A problem with str VS int.
Date: Sat, 9 Dec 2023 23:23:10 -0500
Lines: 46
Message-ID: <mailman.2.1702182195.2892.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
<000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
<000c01da2b20$9655e390$c301aab0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de wWe2SkY7qr+KnrlGNiQC/wRnNDvPq63yICQ7Zq/a33Pw==
Cancel-Lock: sha1:y8K/l6Q3L30e/3lK4h3mLE5vJJs= sha256:Ueit/MPQ3dqnwPLAvjfi4P5iEIDNZ8q5joh9dFcRBmI=
Return-Path: <avi.e.gross@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=K9l4dE7w;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:problem': 0.03;
'variable': 0.05; '2023': 0.07; 'sensor': 0.07; 'comparison':
0.09; 'converting': 0.09; 'else:': 0.09; 'fails': 0.09; 'int':
0.09; 'numeric': 0.09; 'rarely': 0.09; 'received:108': 0.09;
'url:mailman': 0.15; 'expected.': 0.16; 'failed,': 0.16; 'idea.':
0.16; 'indeed': 0.16; 'length.': 0.16; 'strings,': 0.16;
'problem': 0.16; 'message-id:@gmail.com': 0.18; 'to:addr:python-
list': 0.20; 'input': 0.21; 'code': 0.23; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'url-ip:188.166/16': 0.25; 'else': 0.27;
'seem': 0.31; 'url-ip:188/8': 0.31; 'python-list': 0.32; 'but':
0.32; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'though': 0.37; 'way': 0.38; 'two': 0.39; 'valid': 0.39; 'steve':
0.39; 'want': 0.40; 'from:': 0.62; 'to:': 0.62; 'number,': 0.64;
'your': 0.64; 'less': 0.65; 'numbers': 0.67; 'compare': 0.69;
'did,': 0.69; 'order.': 0.69; 'sent:': 0.78; 'converted': 0.84;
'eventually': 0.84; 'saturday,': 0.84; 'you...': 0.84; 'greater':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1702182192; x=1702786992; darn=python.org;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:from:to:cc:subject:date:message-id:reply-to;
bh=7zKPlFc9F6STvANG4L6vcfqvzeSfjiX2EiDwOU9D+sc=;
b=K9l4dE7wRBKqcsq/rCrqyITS+1HosauQaaVyCwIquHOQjL0JLPczHM3v257eRuNgtJ
5D/iilBv/tWvRlUQj84PiwbbnbKtWeyIzC7Xwj8NSusb0/Ip0tpjmkHPgtrHcbalc+Nd
JB1+8BQrNvadO9haYFPyVGctCdEFIXtu/RDwIhK8B+ODmeJFQ3BiuzC9Z6is70lV74ZW
+WK6+SExc4V/JI789PO1/SQPw8mebcCkUFuTjRxa3vbys3zfptXVs2xNECcN8nvR4STj
2TDO76baegvPltpPp+OeHkM8CL7xLlAxxMEoolhmueJI/k6MebKSkvLxfenwF0MVO30Q
sKjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1702182192; x=1702786992;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:to:from
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=7zKPlFc9F6STvANG4L6vcfqvzeSfjiX2EiDwOU9D+sc=;
b=kS78BK9gUUJLn9tjis7s2jbNp/4nKWUoiqaL6GSmm3BuiRtk5IdayHEaoGk01dc6lc
kGTirVVMXhKkB6Mv9AE2mftacd5PQv9zoXQrtPh58wBDFAE2LlByL2LOSMy3GW8zZ/oS
TwRw81gpFMGxCDzIrcKj4HOcRnBwqNNZZJ0YZIhjQKihDDabc0XzUArMsVOwoh5N0fS+
MpJNwH9xKi0ap8RSO592nXyb0LwWYZaOjRJWRbKB3BC28Wg6HSfTWDiGpbDEiHP6lqHm
UYG7WObDF0OMRBhpAvCBjeWs+96RDvvuw1vDHo2P4uRBEghkgpOjHxlZFWJkcxSRjDDi
m9Bw==
X-Gm-Message-State: AOJu0YzxtEmmTJZ/Ca1A5DbfwPhYCpvtt1FjTbnYd4IT9k+kfj2huBCF
u/0mbbPgBWF3nVvedIHb1HkCU6HsqDY=
X-Google-Smtp-Source: AGHT+IGn1rae71S14H8PdudjV/X99EbunDjuVmjlOQ+hGjE61OJChdBqjmobv/1iz3eBjCGTduwWUw==
X-Received: by 2002:a05:622a:1990:b0:425:8868:54ee with SMTP id
u16-20020a05622a199000b00425886854eemr4000600qtc.97.1702182192568;
Sat, 09 Dec 2023 20:23:12 -0800 (PST)
In-Reply-To: <000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQGFlFZVX62qx22fhei3MnUVOAuJigGd9A82AaYHlncCwX+pUAClrY69AgvoZzAAmLm+XwKNKmKpAdaRx5cBx9SKvgIBZ756sL8yT2A=
Content-Language: en-us
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: <000c01da2b20$9655e390$c301aab0$@gmail.com>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
<000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
 by: <avi.e.gross@gmail.com> - Sun, 10 Dec 2023 04:23 UTC

Steve,

I would say converting to a number, as you eventually did, is the way to go.

When you compare character strings, it will not be in numeric order. Compare
"80" with "400" and since 8 is greater than 4, the comparison is over and
"80" is greater then "40" even though 80 is way less than 400.

The only way to get the kind of comparison you want would be to pad with
zeroes so all your "numbers" are the same length. In that case, "080" would
indeed test as less than "400" but rarely does that seem a good idea. If the
user can enter any text, they might enter ".01" or "hello" or al kinds of
nonsense.

If you converted to numbers and tested whether it failed, ...

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Steve GS via Python-list
Sent: Saturday, December 9, 2023 9:42 PM
To: python-list@python.org
Subject: A problem with str VS int.

If I enter a one-digit input or a three-digit number, the code works but if
I enter a two digit number, the if statement fails and the else condition
prevails.

tsReading = input(" Enter the " + Brand + " test strip reading: ")
if tsReading == "": tsReading = "0"
print(tsReading)
if ((tsReading < "400") and (tsReading >= "0")):
tsDose = GetDose(sReading)
print(tsReading + "-" + tsDose)
ValueFailed = False
else:
print("Enter valid sensor test strip Reading.")

I converted the variable to int along with the if statement comparison and
it works as expected.
See if it fails for you...

Steve

--
https://mail.python.org/mailman/listinfo/python-list

Re: A problem with str VS int.

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: A problem with str VS int.
Date: Sun, 10 Dec 2023 00:23:33 -0500
Lines: 36
Message-ID: <mailman.3.1702185827.2892.python-list@python.org>
References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
<000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
<ef2e23a3-6768-410d-b828-f273d0970fca@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de hTDsS+6CXgdt3s0mnvjQagVl7+dFHyzoZ78bAAepXY9A==
Cancel-Lock: sha1:3QtQd+ogLYN7jqd9eOGbgEO72SI= sha256:CzzdlQPoMgYa2w/951DML5pMmoNxGY9NIDv/Y28frCQ=
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=08Vb0WLb;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:problem': 0.03;
'this:': 0.03; 'variable': 0.05; 'sensor': 0.07; 'comparison':
0.09; 'else:': 0.09; 'fail.': 0.09; 'fails': 0.09; 'int': 0.09;
'realistic': 0.09; 'comparing': 0.16; 'expected.': 0.16; 'float,':
0.16; 'preferable': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'whichever': 0.16; 'wrote:': 0.16; 'pm,': 0.19; 'to:addr:python-
list': 0.20; 'input': 0.21; 'code': 0.23; 'lines': 0.23; 'else':
0.27; 'header:User-Agent:1': 0.30; 'think': 0.32; 'python-list':
0.32; 'received:10.0': 0.32; 'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; 'change': 0.36; 'those': 0.36; "it's": 0.37;
'two': 0.39; 'valid': 0.39; 'steve': 0.39; 'something': 0.40;
'want': 0.40; 'try': 0.40; 'lower': 0.62; 'number,': 0.64; 'well':
0.65; 'named': 0.65; 'numbers': 0.67; 'header:Received:6': 0.67;
'received:64': 0.67; 'instead,': 0.70; 'limits': 0.76; '400':
0.78; 'converted': 0.84; 'inputs': 0.84; 'strings': 0.84;
'you...': 0.84; 'legal,': 0.93
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1702185815; a=rsa-sha256;
cv=none;
b=vxMrDsC8DK9zz9TvxHO9e0fZJJfF/QsfPV3k5Nl/gdiz5Jtk4nEUxyiei1Un3SQgi/k/CP
02yIUN3lpoKt/GLSdZbohwhu7gTESo1RkzXjK1C0oSGobfmvc+8hHgzeHH0i4sU2VpqECJ
COMpHgrghmSZzEDhB2ev+A5MQ7L4VQcuSX9HC3ynVUF5zvk+JCD2r1cqYdlcIMEj4QXOeM
c/CgMGEnBAMBhoELL6LXYXVupFSWW8yw75bK0efVwyhnk3655Jyl2XUJYdA2QysRt/X7lz
9q/4DdFNfvoM//RzdKd3f2eUj6Wo2m66Dk2EmF8dGMreR+oJ/G4cApNkgjZnpg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1702185815;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=mFRDNXRGh7n31P0fhDxAPJAS96lnrh11ZKpbj53IiM4=;
b=fKqzcEK7NnG34P8mi9DBnAV07kZmKRi0BqkF+jAIPDmtjX0Ozk7Bw49W4Xh7y3iPaWzqDL
J0DeLP7Ianj5YS2MIlOWQOHlj66gmurDk2qmY5WPLaFjJrIoA11ngwYjMffzhTsA+hkAGK
d+w9GSyVcF8wttoP6P4nRa0MQ3ssDjBlCXGC7fbAYnhts7NTQChYqN1Ur6y/pF5ocv92Gv
FFrI/mKkQ3RYr5+muUCsRMzPqVgwpDE0a01h8v1RC9pCPEQG3YTPpJu+Vr1RaHgKNdoCSU
Vp20uOqyBheT77OdIi1gIRPgvCTNaJ05w7oTszaLriQ4tOoK86vMVEVQgcyLKQ==
ARC-Authentication-Results: i=1; rspamd-5749745b69-wztck;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Whispering-Glossy: 3c9bf8dd4f2a5b7d_1702185815598_967929159
X-MC-Loop-Signature: 1702185815598:3146083238
X-MC-Ingress-Time: 1702185815597
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1702185815;
bh=mFRDNXRGh7n31P0fhDxAPJAS96lnrh11ZKpbj53IiM4=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=08Vb0WLbQmLdknteh2e6Mt6XSTfX4budQGB9Cd+mu+zrPU5o4mktX9hnzdzZFSxoH
5S2tKBtoeqm9gF6l60RCBnvG9hgtV0AP5qzmCWmzvRgoavyuKc6NinX8m+AYyzAT6b
r443k71J/MgLVzW0vmpfGmRY6QatDS6ocb90MISlq3sdNJ3q04FYO7NLfx4LnG8tiN
UeVPQj0m1D5r7m31+mRIoemuGt8m2O4TQd4T540JuR7cKlMvrS8fRHV2P9824kHUPk
HgqnQChdzBt6UAwfd/iModwlZdJw3oxks2jpammQvw2AZ42xDL5rNLX55ow9OdXpFf
odMpOpx5w0cxg==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
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: <ef2e23a3-6768-410d-b828-f273d0970fca@tompassin.net>
X-Mailman-Original-References: <r5p34k-5li5.ln1@esprimo.zbmc.eu>
<459067d1-4ec4-4263-8be9-4101f525d4d1@mrabarnett.plus.com>
<6ee95034-135f-474c-8f09-13deafa9f428@tompassin.net>
<mailman.330.1701836673.3828.python-list@python.org>
<ilr54k-24m9.ln1@esprimo.zbmc.eu>
<B0F50A98-64C6-4B86-B809-44E3320E20D3@barrys-emacs.org>
<dc8f37ec-16ee-4203-ba7f-d07aba493359@tompassin.net>
<a0f98880-81f3-4779-acef-351dab68377f@mrabarnett.plus.com>
<599b264e-28e8-4b07-ae4c-2c118b3ff0c0@DancesWithMice.info>
<2fa9fe88-efed-469b-885b-a62c7ff53225@mrabarnett.plus.com>
<000401da2b12$7756e4c0$6604ae40$@SGA.Ninja>
 by: Thomas Passin - Sun, 10 Dec 2023 05:23 UTC

On 12/9/2023 9:42 PM, Steve GS via Python-list wrote:
> If I enter a one-digit input or a three-digit number, the code works but if I enter a two digit number, the if statement fails and the else condition prevails.
>
> tsReading = input(" Enter the " + Brand + " test strip reading: ")
> if tsReading == "": tsReading = "0"
> print(tsReading)
> if ((tsReading < "400") and (tsReading >= "0")):
> tsDose = GetDose(sReading)
> print(tsReading + "-" + tsDose)
> ValueFailed = False
> else:
> print("Enter valid sensor test strip Reading.")
>
> I converted the variable to int along with the if statement comparison and it works as expected.
> See if it fails for you...

I don't have to try it to know it will fail. You think you are
comparing numbers but you are comparing strings instead, which won't
work as you expect.

You would do better to convert the inputs and limits to numbers, as well
as the GetDose() function. In a more realistic version, you would also
have to make sure the user input is legal, either an int or a float,
whichever you want to work with.

And along those lines (a more realistic version), it would be preferable
to change the limits to be named constants, which will make the code
easier to understand and change when it's revisited later. Something
like this:

UPPER = 400
LOWER = 0
# ...
if LOWER < value < UPPER:
# .....


devel / comp.lang.python / How/where to store calibration values - written by program A, read by program B

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor