Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help adapting code
#1
Good morning to all!
I'm trying to change a python script to have a slightly different behaviour, but I'm stuck with this.

I have a Class: #pseudo code
Class pairs:
    _pairs = {}
    def append(self, string1, string2)):
    return self._pairs[string1][string2]
And have an Exec function inside an invoke: #pseudo code
    self.pairs = pairs()
    for i in range(max_number):
        exec((self.pairs.append({0}.string1, {0}.string2).format('prefs', i))
I'm trying to get the info of string1 and string2 from a txt file, using each line as number (max_number).
I have this to parse the txt file but don't know how to use the info and put inside the exec function, replacing the string1 and string2 data with the data from my txt(is inside the invoke):
    with open(alias_path, "r") as alias:
        line_count = 0
        for line in alias:
            if not line.startswith("#"):
                line_count += 1
                parameters =[]
                for elements in line.split(", "):
                    parameters.append(elements)
Can you help me, please?
Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Difficulty in adapting duplicates-filter in script ledgreve 5 879 Jul-17-2023, 03:46 PM
Last Post: ledgreve

Forum Jump:

User Panel Messages

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