How do i make a local variable global across the whole script?

Hi. I’m trying to make sense of my old script Paketti and am just thinking, is there in the year 2022 a way to actually just set

t=renoise.song().transport

so that it’s always there everywhere all over the script everywhere, regardless of whether there’s a separate sub-script being imported, or if it is called in multiple functions within the script?

Wasn’t that answered here?

not really no, because the minute i put in s=renoise.song() i lose all my shortcuts and have to remove the line and then re-create all the shortcuts. it is immensely destructive when one has to, you know, re-bind something to the tone of 50 (and i was only getting started bringing Paketti features into my Renoise M1 installation) shortcuts.

Maybe its how the code is written, because as suggested:

“So, as you might understand it’s actually bad practice not to prefix things with local, unless you want to risk variables clashing with each other”

“PS. I think that avoiding the use of global variables will generally lead to better coding practice.”

Seems you have some clashing goin on?

How is this even happening?

Well, because when Renoise is started, there is no renoise.song() - so setting it as a global variable doesn’t work at all. i’d need to learn how to protect myself against this, and that’s way above my paygrade.

You need an event handler for when a song (AKA ‘doc’) is loaded.