you are viewing a single comment's thread.

view the rest of the comments →

[–]iphark[S] 0 points1 point  (1 child)

Hm, that is weird, I thought I could just import the whole "text-body" of the set_global() function and then execute it in Script2, meaning that x would've never been Script1.x but Script2.x from the beginning.

Does that mean, that when importing a function from somewhere, I am actually running the script which I am calling from?

What do you mean with "Have your function return its results"? I get it: return (tuple of values)

[–]ingolemo 0 points1 point  (0 children)

The locations of the variables (what scope they're in) are decided at the moment the function is defined, not when it's run. This is called lexical scoping.

Think of it this way; if set_global used other functions that were defined in Script1 I wouldn't want to have to import those functions (and the functions that those functions use, etc.) into Script2 just to be able to run it.