Python Info & Resources

Discussions concerning programming of SOFTIMAGE©
EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 01:41

Python Info & Resources

Post by EricTRocks » 17 Oct 2012, 11:29

This thread is reserved for information regarding the use of python inside Softimage.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 18:28

Re: Python Info & Resources

Post by iamVFX » 17 Oct 2012, 20:14

XSI Scripting Using Python: http://s3.darkvertex.com/mirror/XSIScri ... Python.pdf
Good PDF to read.

Python copy-paste gotchas: https://vimeo.com/27061025
You better use white spaces for indentation. You can convert tabs by checking "Insert spaces instead of tabs" option in File -> Preferences... window of the Script Editor.

User avatar
rray
Moderator
Posts: 1570
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Python Info & Resources

Post by rray » 17 Oct 2012, 20:39

Something that's worth considering before writing tools, filters etc that are supposed to deal with large geos in python..
A ->python/JS/VBS/C# benchmark I did a while ago

Results speed wise weren't in favor of python (**) when iterating through subcomponents, it performed around 30 times slower than the fastest language, VBScript.

Code: Select all

(lower is better)
  VBScript: Execution Time = 93 ms
   JScript: Execution time = 113 ms
        C#: Execution time = 576 ms
    Python: Execution time = 3388 ms
(**) or rather the softimage python API
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
gustavoeb
Moderator
Posts: 587
Joined: 21 Jul 2010, 00:33
Skype: gustavoboehs

Re: Python Info & Resources

Post by gustavoeb » 17 Oct 2012, 21:34

http://ocw.mit.edu/courses/electrical-e ... -lectures/

This is a GREAT introduction to programing. It is very long too, but is free and of incredible quality. Python is the language used for all examples in the lecture, but it goes far beyond your average scripting tutorial. Which is good, but also time consuming...
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

User avatar
Hirazi Blue
Administrator
Posts: 4918
Joined: 04 Jun 2009, 12:15

Re: Python Info & Resources

Post by Hirazi Blue » 17 Oct 2012, 22:36

First things first, I’d say. I strongly recommend anyone beginning with Python to get themselves a good old-fashioned book on the language itself. The list of good Python books is quite long, do search one that suits you and read the first couple of chapters thoroughly, before even thinking about doing anything with Python in Softimage. Make sure you get a book on Python 2.* as Python 3 isn’t supported by Softimage.
And don’t let comparison benchmarks scare you off. At least not initially… :D

Scripting isn't much harder than "our" beloved ICE, it just asks for a different way of doing (basically the same set of) things ("writing code" instead of "plugging nodes"). If you know you're way around an ICE Tree a little bit, most of the concepts of Python shouldn't be that hard to grasp!!!
...

User avatar
rray
Moderator
Posts: 1570
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Python Info & Resources

Post by rray » 17 Oct 2012, 23:48

On a more constructive note :D ... here's something that's just popped up on my Google+ feed, (Re)posted by Anthony Flores.. Not directly Python-in-Softimage related, but looks like a cool way to overcome those initial hurdles...

Online Python Tutor - Learn programming by visualizing code execution
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: Python Info & Resources

Post by csaez » 18 Oct 2012, 02:11

iamVFX wrote:You better use white spaces for indentation. You can convert tabs by checking "Insert spaces instead of tabs" option in File -> Preferences... window of the Script Editor.
Just a quick note...

PEPs (Python Enhancement Proposals) are just that, proposals. There're a lot of discussions about using tabs vs spaces and there're a lot of people using tabs without issues... so is up to you (or your company).
The SDK wizard use tabs instead of spaces so you have to convert them by your own (in almost every editor do you have an automated way to do it, not big deal).

Cheers!

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 01:41

Re: Python Info & Resources

Post by EricTRocks » 18 Oct 2012, 04:05

Spaces instead of tabs is super useful other than just because. If you copy / paste code in various editors, IM clients, and email clients, they can be badly formed if you use tabs. I used to use tabs but have switched. The fact that the wizard doesn't take your preferences into consideration when generating code is not a valid argument for using tabs. Its a bug in my eyes.
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: Python Info & Resources

Post by csaez » 18 Oct 2012, 04:45

EricTRocks wrote:Spaces instead of tabs is super useful other than just because. If you copy / paste code in various editors, IM clients, and email clients, they can be badly formed if you use tabs. I used to use tabs but have switched. The fact that the wizard doesn't take your preferences into consideration when generating code is not a valid argument for using tabs. Its a bug in my eyes.
That wasn't an argument defending tabs, just something to be aware.
I'm just saying PEPs are just proposals and not a mandatory thing. Both indentation methods works well enough for production code, just don't mix them.
The spaces vs tabs is a kind of holy war and I dont wanna go there.

BTW, I use spaces for personal projects and whatever my company choose at work, so no big deal for me...

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 01:41

Re: Python Info & Resources

Post by EricTRocks » 18 Oct 2012, 04:47

Yeah I think the biggest thing is what you mentioned in that you should mix them. :D
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken