Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary generator
#4
(Jul-20-2021, 04:30 PM)bowlofred Wrote: That depends on you and what you want. The code you have above needs some tweaks (Some of the "V" are not quoted and it looks like none of the "Hz" are quoted). But otherwise it creates a dictionary from static data.

If you want to create a dictionary from dynamic data, you need to figure out where the data will come from. A file? CLI input? Database? GUI?
Yes, "V" need to quote (its my mistake)
all data come from CLI input
(Jul-20-2021, 04:36 PM)deanhystad Wrote: What does your input look like? Is it something like this?
10 V 50 Hz 9 V
10 V 60 Hz 9 V
10 V 4000 Hz 9 V
...
1100 V 400 Hz 200 V

Are you forced to use a dictionary? I think a classes would work better.

In fact, I don't know how it is better to arrange, as an option I use the dictionary at the moment.

The essence of the problem: I manage the electronic devices - the calibrator and the multimeter. The multimeter is set by the range (10, "V"), then the calibrator is set to the frequency (50, "Hz"), and the voltage (9, "V"), the multimeter measures this voltage, then the frequency (60, "Hz") , and voltage (9, "V") and so on as in the example.

Maybe you will advise how it is more correct or better to arrange, since I have such a fluent.
(Jul-20-2021, 04:30 PM)bowlofred Wrote: That depends on you and what you want. The code you have above needs some tweaks (Some of the "V" are not quoted and it looks like none of the "Hz" are quoted). But otherwise it creates a dictionary from static data.

If you want to create a dictionary from dynamic data, you need to figure out where the data will come from. A file? CLI input? Database? GUI?
or may be the best decision - its read data from file, which I will prepare in advance?
Reply


Messages In This Thread
Dictionary generator - by Irv1n - Jul-20-2021, 04:12 PM
RE: Dictionary generator - by bowlofred - Jul-20-2021, 04:30 PM
RE: Dictionary generator - by Irv1n - Jul-20-2021, 04:56 PM
RE: Dictionary generator - by deanhystad - Jul-20-2021, 04:36 PM
RE: Dictionary generator - by Yoriz - Jul-21-2021, 10:11 PM
RE: Dictionary generator - by naughtyCat - Aug-18-2021, 06:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  receive from a generator, send to a generator Skaperen 9 5,572 Feb-05-2018, 06:26 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020