Wed, Dec 4, 8:47 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Defense from other script


JTrout ( ) posted Sat, 11 September 2010 at 3:50 AM · edited Wed, 04 December 2024 at 2:30 PM

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


3dvice ( ) posted Mon, 13 September 2010 at 6:07 AM

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


nruddock ( ) posted Mon, 13 September 2010 at 12:13 PM

You can always reference standard methods by using the builtin module :-

import __builtin__<br></br>__builtin__.str()

See the docs for additional info.


JTrout ( ) posted Mon, 13 September 2010 at 1:31 PM

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


nruddock ( ) posted Mon, 13 September 2010 at 2:01 PM

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).


JTrout ( ) posted Mon, 13 September 2010 at 2:55 PM

Hi,

Thank you again.


markschum ( ) posted Mon, 13 September 2010 at 3:38 PM

You might try reinitializing python from the file menu option and see if that helps.


Privacy Notice

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.