| Author |
Message |
Cheiron

Joined: 21 Apr 2005 Posts: 388 Location: Copenhagen, Denmark
|
Posted: Sun Jan 13, 2008 3:24 pm Post subject: globals |
|
|
the question is short and sweet:
what is difference between just declaring a global inside a script and declaring global in the field at top of script editor?  _________________ Cheiron
______________________________
"Any scientist with respect for himself should start
the day by rejecting his own pet hypotheses".
(Konrad Lorenz)
"Wir müssen wissen
Wir werden wissen"
(David Hilbert) |
|
| Back to top |
|
 |
Scotsman Site Admin

Joined: 03 Aug 2004 Posts: 705 Location: MadWolf Software
|
Posted: Mon Jan 14, 2008 12:43 am Post subject: |
|
|
The short answer is scope. Yeah real helpful I know.
From Learning Python (O'Reilly publishers) page 104
The global statement is the only thing that's anything like a declaration in Python. It tells Python that a function plans to change global names -- names that live in the enclosing module's scope (namespace). We've talked about global in passing already; as a summary:
* global means "a name at the top-level of a module file."
* global names must be declared only if they are assigned in a function.
* global names may be referenced in a function without being declared.
Also there are several documents at http://www.python.org/doc/ that may be helpful. |
|
| Back to top |
|
 |
Bri

Joined: 06 Aug 2004 Posts: 237 Location: Palm Springs, CA
|
Posted: Mon Jan 14, 2008 3:53 am Post subject: Hmmmm |
|
|
always thought the global statement is used to allow access to a global variable, not to declare one. _________________ RL..now with 100% less lag! |
|
| Back to top |
|
 |
Studio 12 Site Admin

Joined: 04 Aug 2004 Posts: 67
|
Posted: Mon Jan 14, 2008 9:42 am Post subject: |
|
|
The other haft of the answer is.
I believe the global field at the top of the script editor is for delclaring a script "global" for the whole server. You have to enter the room which it resides in for it to load. _________________ Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic. |
|
| Back to top |
|
 |
Scotsman Site Admin

Joined: 03 Aug 2004 Posts: 705 Location: MadWolf Software
|
Posted: Mon Jan 14, 2008 3:39 pm Post subject: |
|
|
So did I Bri, but apparently I was mistaken. Going to have to play with it a little bit now that had to go look up the info for Cheiron.
That's correct Studio, that field allows you to declare a module name to detach the script into so it is not purged from memory when you leave the room. |
|
| Back to top |
|
 |
Cheiron

Joined: 21 Apr 2005 Posts: 388 Location: Copenhagen, Denmark
|
Posted: Tue Jan 15, 2008 12:24 am Post subject: |
|
|
| Scotsman wrote: |
That's correct Studio, that field allows you to declare a module name to detach the script into so it is not purged from memory when you leave the room. |
AHA !.... now we are getting somewhere.
well...back to reading about python.....
I will be back...... lol _________________ Cheiron
______________________________
"Any scientist with respect for himself should start
the day by rejecting his own pet hypotheses".
(Konrad Lorenz)
"Wir müssen wissen
Wir werden wissen"
(David Hilbert) |
|
| Back to top |
|
 |
|