Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
I just started with Python a little while ago, so I'm probably not the right person to answer your question, but I'll give it a try and maybe somebody else will join in to give more detailed or better answer:
Quote - Is each script execution in the same process/name_space unless the Poser is finished?
Yes.- The variable and its value stays alive, even when your script is finished, and the value can be changed/overwritten by another script.
> Quote - What kind of coping (self-defense) is possible for the programmer to such a problem which occurs from other's scripts?
You can initialize/define your variables inside a function or encapsulate them in an object.
Le cinéma substitue à notre regard un monde qui s'accorde à nos désirs. - André Bazin
Hi, 3dvice, nruddock.
Thank you for your reply.
I didn't know a "builtin" module.
I saw your reply, and found that at the beginning of "Global Module Index" just now.
My worry was solved.
Thank you very much.
Incidentally, if independence between the script isn't guaranteed......
I think that the use of the global variable in the Python Script of Poser should be restricted.
I think that the wrapper class or the wrapper function to execute user's logic should be prepared.
By the way, which document is "docs for additional info." concretely?
JTrout
Attached Link: http://docs.python.org/release/2.4.2/lib/builtin.html#builtin
> Quote - By the way, which document is "docs for additional info." concretely?See attached link (or the local equivalent on your disk).
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
Hi,
There is the script which a specific built-in function is overwritten in.
Then, after that script is executed, the script which a specific built-in function is used in doesn't work properly.
For example, "str" is overwritten as a variable in the "setLightStyle.py" of the Wacros.
Because of that, a str() function can't be used any more after that script practice.
There may be other similar script, too.
Is each script execution in the same process/name_space unless the Poser is finished?
What kind of coping (self-defense) is possible for the programmer to such a problem which occurs from other's scripts?
For example, as for "setLightStyle.py", it seems it can be avoided by putting the following statement on the start of my script.
del str
However, is this suitable?
Generally it is not only "str", and such an ad hoc code is unpleasant in the first place.
What is a suitable avoidance means?
Kind regards,
JTrout