Kodi Community Forum
__foo__ global variables. Are they mandatory/needed? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: __foo__ global variables. Are they mandatory/needed? (/showthread.php?tid=376369)



__foo__ global variables. Are they mandatory/needed? - cramm - 2024-02-21

Hi all,

Several years ago I adopted a subtitles add-on and its service.py file included lines like this at the top:

Code:

__addon__ = xbmcaddon.Addon()
__author__ = __addon__.getAddonInfo("author")
__scriptid__ = __addon__.getAddonInfo("id")
__scriptname__ = __addon__.getAddonInfo("name")
__version__ = "x.y.z"
__language__ = __addon__.getLocalizedString

__cwd__ = xbmcvfs.translatePath(__addon__.getAddonInfo("path"))
__profile__ = xbmcvfs.translatePath(__addon__.getAddonInfo("profile"))


A GitHub [1]search finds many occurrences of them in different Kodi addon repositories.

But e.g. I don't find them in Kodi's own codebase (searched for [2]__scriptid__).
Also, in the https://kodi.wiki site add-ons documentation section there is no formal mention of them as something that needs to be present, although an [3]article there that teaches how to create a minimal GUI add-on has a couple of them.

Are these actually mandated for an add-on to work correctly? Is it a[n old] convention of some sort?

Thanks,

1. https://github.com/search?q=path%3Aservice.py+__addon__&type=code
2. https://github.com/search?q=repo%3Axbmc%2Fxbmc%20__scriptid__&type=code
3. https://kodi.wiki/view/GUI_tutorial


RE: __foo__ global variables. Are they mandatory/needed? - jjd-uk - 2024-02-21

I can't answer you question/s as I do nothing with addons, but maybe these wiki pages might help

https://kodi.wiki/view/Add-on_structure
https://kodi.wiki/view/About_Add-ons


RE: __foo__ global variables. Are they mandatory/needed? - sarbes - 2024-02-21

Those are just "aliases" you are defining yourself. If you don't use them, you don't need them.


RE: __foo__ global variables. Are they mandatory/needed? - Roman_V_M - 2024-02-21

It's just an old naming convention that has no special meaning. I usually use ALL_CAPS naming for globals but it's just a matter of a preferred code style.