Is there a way to abbreviate the following code somehow?
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
Is there a way to abbreviate the following code somehow?
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
It's effectively a 'table' with columns named 'dev', 'input' and
'name' and I want to access the values of the table using the variable
name.
I could, obviously, store the data in a database (sqlite), I have some similar data in a database already but the above sort of format in
Python source is more human readable and accessible. I'm just looking
for a less laborious way of entering it really.
Chris Green <cl@isbd.net> wrote:
Is there a way to abbreviate the following code somehow?Or, more sensibly, make the above into a list (or maybe dictionary)
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
It's effectively a 'table' with columns named 'dev', 'input' and
'name' and I want to access the values of the table using the variable
name.
of dictionaries:-
adccfg = [
{'abbr':'lv', 'dev':'bbb', 'input':'1', 'name':'Leisure volts'},
{'abbr':'sv', 'dev':'bbb', 'input':'0', 'name':'Starter volts'},
{'abbr':'la', 'dev':'bbb', 'input':'2', 'name':'Leisure Amps'},
{'abbr':'sa', 'dev':'bbb', 'input':'3', 'name':'Starter Amps'},
{'abbr':'bv', 'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
]
This pickles nicely, I just want an easy way to enter the data!
On 2023-12-11, Chris Green <cl@isbd.net> wrote:
Chris Green <cl@isbd.net> wrote:
Is there a way to abbreviate the following code somehow?Or, more sensibly, make the above into a list (or maybe dictionary)
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
It's effectively a 'table' with columns named 'dev', 'input' and
'name' and I want to access the values of the table using the variable
name.
of dictionaries:-
adccfg = [
{'abbr':'lv', 'dev':'bbb', 'input':'1', 'name':'Leisure volts'},
{'abbr':'sv', 'dev':'bbb', 'input':'0', 'name':'Starter volts'},
{'abbr':'la', 'dev':'bbb', 'input':'2', 'name':'Leisure Amps'},
{'abbr':'sa', 'dev':'bbb', 'input':'3', 'name':'Starter Amps'},
{'abbr':'bv', 'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
]
This pickles nicely, I just want an easy way to enter the data!
adccfg = [
dict(zip(('abbr', 'dev', 'input', 'name'), row))
for row in (
('lv', 'bbb', '1', 'Leisure volts'),
('sv', 'bbb', '0', 'Starter volts'),
('la', 'bbb', '2', 'Leisure Amps'),
('sa', 'bbb', '3', 'Starter Amps'),
('bv', 'adc2', 0, 'BowProp Volts'),
)
]
Chris Green <cl@isbd.net> wrote:How about:
Is there a way to abbreviate the following code somehow?Or, more sensibly, make the above into a list (or maybe dictionary)
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
It's effectively a 'table' with columns named 'dev', 'input' and
'name' and I want to access the values of the table using the variable
name.
of dictionaries:-
adccfg = [
{'abbr':'lv', 'dev':'bbb', 'input':'1', 'name':'Leisure volts'},
{'abbr':'sv', 'dev':'bbb', 'input':'0', 'name':'Starter volts'},
{'abbr':'la', 'dev':'bbb', 'input':'2', 'name':'Leisure Amps'},
{'abbr':'sa', 'dev':'bbb', 'input':'3', 'name':'Starter Amps'},
{'abbr':'bv', 'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
]
This pickles nicely, I just want an easy way to enter the data!
I could, obviously, store the data in a database (sqlite), I have some
similar data in a database already but the above sort of format in
Python source is more human readable and accessible. I'm just looking
for a less laborious way of entering it really.
Is there a way to abbreviate the following code somehow?
lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'}
sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'}
la = {'dev':'bbb', 'input':'2', 'name':'Leisure Amps'}
sa = {'dev':'bbb', 'input':'3', 'name':'Starter Amps'}
bv = {'dev':'adc2', 'input':0, 'name':'BowProp Volts'}
It's effectively a 'table' with columns named 'dev', 'input' and
'name' and I want to access the values of the table using the variable
name.
I could, obviously, store the data in a database (sqlite), I have some similar data in a database already but the above sort of format in
Python source is more human readable and accessible. I'm just looking
for a less laborious way of entering it really.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 57:46:57 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,561 |