Tue, Nov 19, 9:15 AM 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 Sep 18 2:50 am)

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: Python Print Statement (and error messages) Stop Showing Up?


OberonRex ( ) posted Sat, 23 December 2023 at 12:04 PM · edited Tue, 19 November 2024 at 7:31 AM

I'm debugging a python script and, occasionally, print in python stops working, plus errors in python don't print either.  Simplly no output box shows up.

When this occurs the only thing that seems to get it working again is to close Poser and reopen it. Also, when it occurs, *none* of my scripts will print anything nor show python errors.

Is there some way to turn back on that output box, short of restarting Poser?

This is Poser 13 under Windows 11.


HartyBart ( ) posted Sat, 23 December 2023 at 11:41 PM

You're aware that 'print' is one of the key changes between Python 2 (Poser 11 and predecessors) and Python 3 (Poser 12 and up)? It sounds like perhaps you're trying to run a Python 2 script in a Python 3 environment. Print statements, strings, and iterated lists are handled differently.  Print is fairly easily fixed though.



Learn the Secrets of Poser 11 and Line-art Filters.


OberonRex ( ) posted Sun, 24 December 2023 at 7:40 AM

Nah, it was something more subtle than that.

I was using print statements for debugging a script. It had four print statements. I would open Poser, load my scene, run the script -- and three prints would work. I would rerun the script and the print box would not even open, not for that script nor for any of my other scripts. I would relaunch Poser and the script would print again. Three statements printed. The fourth did not, and, as before, the script would no longer even open the print box. I would have to relaunch Poser again.

Inexplicably enough, changing the line, "str = input.Value()", gleamed from working code, to use "x" as the variable name instead of "str" -- and the problem went away. Makes no sense at all, but, trust me, I have over 50 years experience as a programmer. Changing that line of code (which is *still* in another working piece of code) did the magic. No clue. Maybe there was a non-printing character in the statement or somesuch, but whatever was going on, it screwed scripts royally, requiring closing and reopening Poser to clear it.

Thank you for your suggestions however. This forum really works well for getting answers, suggestions, clues, etc., and I love it.


HartyBart ( ) posted Sun, 24 December 2023 at 4:00 PM · edited Sun, 24 December 2023 at 4:01 PM

Curious. Is there a limit on str (string?) print statements, perhaps?



Learn the Secrets of Poser 11 and Line-art Filters.


OberonRex ( ) posted Sun, 24 December 2023 at 4:07 PM

I've been having this problem off and on today whilst dabbling with a set of scripts for adjusting groups of lights by f-stops. And -- it may turn out to be that I was crashing Python by trying to invoke a method on a null object. I haven't done testing to nail that down, but it makes more sense than thinking that "str" was actually and truly a magically taboo variable name.


Bastep ( ) posted Mon, 25 December 2023 at 1:40 AM · edited Mon, 25 December 2023 at 1:41 AM

From: https://docs.python.org/3/library/stdtypes.html#str

class str(object='') class str(object=b'', encoding='utf-8', errors='strict')

Return a string version of object. If object is not provided, returns the empty string. Otherwise, the behavior of str() depends on whether encoding or errors is given, as follows.

If neither encoding nor errors is given, str(object) returns type(object).__str__(object), which is the “informal” or nicely printable string representation of object. For string objects, this is the string itself. If object does not have a __str__() method, then str() falls back to returning repr(object).

If at least one of encoding or errors is given, object should be a bytes-like object (e.g. bytes or bytearray). In this case, if object is a bytes (or bytearray) object, then str(bytes, encoding, errors) is equivalent to bytes.decode(encoding, errors). Otherwise, the bytes object underlying the buffer object is obtained before calling bytes.decode(). See Binary Sequence Types — bytes, bytearray, memoryview and Buffer Protocol for information on buffer objects.

Passing a bytes object to str() without the encoding or errors arguments falls under the first case of returning the informal string representation (see also the -b command-line option to Python). For example:

>>>
str(b'Zoot!')
"b'Zoot!'"

For more information on the str class and its methods, see Text Sequence Type — str and the String Methods section below. To output formatted strings, see the f-strings and Format String Syntax sections. In addition, see the Text Processing Services section.



OberonRex ( ) posted Mon, 01 January 2024 at 10:45 AM

Thanks for the information, but, actually, str is not a protected keyword and can definitely be used as a variable name. I've downloaded code from this forum which uses it as a variable name, as does much of my derived code. The issue was a typo a line or so earlier, such that I was referencing a null object in the line which was assigning a value to str.


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.