1

I have a python dictionary in one of my project files structured like so:

DICTIONARY = {"Item": {"property1": "something",
                       "property2": "something2"},
              "Item2": {"property1": "something",
                        "property2": "something2"},
              "Item3": {"propertylist": {"property": "something",
                                         "property": "something"}
                        }
              }

I am building a GUI which should take user input and use it to append new entries to the end of the dictionary.

How can i add entries to a dictionary in one of my other project files?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 1
    After `from myOtherProjectFile import DICTIONARY`, you can use the dict exactly as if it was defined in the current file. Note that any changes will only exist during the current run of the program, if you want permanent changes that's somewhat more complicated. – jasonharper Dec 08 '21 at 22:15
  • I do need permanent changes, do you know how i could do that? – Justin Holl Dec 08 '21 at 22:44
  • @Justin Please [edit] the question to include all your requirements. For example, the solution might be as simple as using a JSON file instead of a Python file, or as relatively complicated as a database or a [shared dict](/q/6832554/4518341) (though I have no experience with those two myself). BTW, welcome to Stack Overflow! Check out [ask] if you want tips. – wjandrea Dec 08 '21 at 23:42

0 Answers0