Setting global variables

Hi
How do you and where do you declare a global variable ?
Thanks

Hi Suresh, welcome to the community!

I split this out into a new thread as it seemed like its own question.

In Python you can declare a global variable using the global keyword. However if you are just wanting to use a variable throughout your Mycroft Skill it is best to declare an instance variable. You can see an example in the Hello World Skill where we have:

self.learning = True

self here refers to our instance of the MycroftSkill class so we can then access that variable anywhere in the HelloWorldSkill

Is that what you were meaning?

Hi
thank you
i figured out that I can use the Skills settings feature to do what i needed.
I needed to have persistence across skill invocation and by using skills.settings I was able to accomplish that.
(e.g.) I wrote a simple password setting skill. But I wanted to see if the password had already been sit and if so, wanted to have a different dialog.
thank you

1 Like