Page 1 of 1

Python Info & Resources

Posted: 17 Oct 2012, 11:29
by EricTRocks
This thread is reserved for information regarding the use of python inside Softimage.

Re: Python Info & Resources

Posted: 17 Oct 2012, 20:14
by iamVFX
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.

Re: Python Info & Resources

Posted: 17 Oct 2012, 20:39
by rray
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

Re: Python Info & Resources

Posted: 17 Oct 2012, 21:34
by gustavoeb
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...

Re: Python Info & Resources

Posted: 17 Oct 2012, 22:36
by Hirazi Blue
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!!!

Re: Python Info & Resources

Posted: 17 Oct 2012, 23:48
by rray
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

Re: Python Info & Resources

Posted: 18 Oct 2012, 02:11
by csaez
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!

Re: Python Info & Resources

Posted: 18 Oct 2012, 04:05
by EricTRocks
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.

Re: Python Info & Resources

Posted: 18 Oct 2012, 04:45
by csaez
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...

Re: Python Info & Resources

Posted: 18 Oct 2012, 04:47
by EricTRocks
Yeah I think the biggest thing is what you mentioned in that you should mix them. :D

Re: Python Info & Resources

Posted: 23 Mar 2022, 19:26
by AdrusBarba
Any use of Fast APIs?