Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
Of the three, I'd always go with the last style. I use to find it extremely frustrating to go back to a script months after writing it and have to spend a lot of time trying to figure out what I'd done earlier. Being more verbose and breaking steps up into individual lines helps that greatly. Also a nice comment block for each proc with an explanation of what it's suppose to be doing, what the inputs and outputs are and an overview of the intended algorithm are very useful when updating old code.
If you want your scripts to be Poser Pro Pack compatible, then you also need to call string methods using the 'string' module instead of the object way. So;
vline = l.split()
would become
vline = string.split(l)
Although, I understand that the 'string' module will (or has been) be depreciated and dropped in later python releases.
Maintaining Pro Pack compatibility can be a chore sometimes.
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.
This is probably a stupid question but I would like your advice. What's the best way to write this?
This:
or this: vertex = l.split(' ',1)[1].split()
self.vertices.append(map(float,vertex))
or this: vLine = l.split()
vertex = vLine[1:]
self.vertices.append(map(float,vertex))
They are all meant to take the a string 'v 1.0 2.0 3.0' and return a list [1.0,2.0,3.0] where each item in the list has been converted to a float.
The first obviously takes up less space but isn't as readable. Does it matter?
Thanks.