Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Python help, how to set a value above definitions

$
0
0

Hi guys, a noob Python question here.
My scripts are becoming more complex and need better control. I have a few definitions in the script and need to have some variables that are accessible above them so I don’t have to return the value via the definition. What is the best approach?

I have used sticky as a simple workaround, but I am sure there are better options.

Super simple example:

import rhinoscriptsyntax as rs

string = "Nothing"

def setString():
    string = "Something"

def getString():
    print string

setString()
getString()

returns “Nothing”

12 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles