M
M
Matvey2021-11-27 20:33:55
Python
Matvey, 2021-11-27 20:33:55

How to open another python file and overwrite the data in the dictionary?

You need to open the config.py file from the main bot.py
Then extract the data from the dictionary from the config, output and overwrite

How to open it, put it in a variable, and then overwrite it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vindicar, 2021-11-27
@Vindicar

mlt_melt , don't mess with the bike, use the json module . You will be fine with storing structured data - as long as they can be represented as a part-whole set.
And if the connections are more complex, for example, there is a list of users and you need to store who is friends with whom, then it’s time to think about a relational database.

S
Sergey Novikov, 2021-11-27
@snovikov

It is not clear what "overwrite" means.
Are you going to make a change to the source file?
If so, then this is imho not an "Orthodox" approach.
Why don't you want to store the configuration in an ini file?
If you want to dynamically import modules, read about importlib.
Describe the scenario in more detail. It is not entirely clear why you are going to change the source code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question