A
A
Andrew2020-05-16 22:53:16
Python
Andrew, 2020-05-16 22:53:16

How to replace global variables?

The point is the following.
There is a python bot, but I use global variables there (here is such a "simple person"). And at the moment when another (new) user "started" a conversation with the bot, these variables are "overwritten" by the latest ones.
Global variables 3. The algorithm is as follows:

  • 1 - question NAME (response to the global variable name)
  • 2 - age question (global age)
  • 3 - question car (global car).

And at the end, a record is formed in the file, and the response is sent to the user:
"{} - {} - {}".format(name, age, car)
Tell me, how to get rid of the global ones? Dig towards the class? Can I have an example?
Thanks for the help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MechanicZelenyy, 2020-05-17
@MechanicZelenyy

Yes, write your own class, and create instances of it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question