PDA

View Full Version : "import sys" : when do you need it, when do you NOT need it?



jeric_synergy
09-22-2015, 11:26 PM
ummm, that's about it:

"import sys" : when do you need it, when do you NOT need it?

ernpchan
09-22-2015, 11:36 PM
When you need something in the sys module.

jeric_synergy
09-23-2015, 01:19 PM
And that's in the C sdk?

ernpchan
09-23-2015, 01:22 PM
Hm, it's more like a generic python module.
https://docs.python.org/2/library/sys.html

It's not specific to LW.

jeric_synergy
09-23-2015, 02:31 PM
Looking over these functions, I'm still wondering why the example script I was looking at (native LW) used import sys. And now I can't find which one it was.....

ernpchan
09-23-2015, 08:24 PM
You can see if it's using sys.(something) in the script. That'll show you where and what is being used.

jeric_synergy
09-24-2015, 07:30 PM
You can see if it's using sys.(something) in the script. That'll show you where and what is being used.

In the native "scatter_objects.py" script, Bob Hood uses "import sys", but that's the last occurrence of "sys" in the script.

Was it just redundant?

ernpchan
09-24-2015, 08:41 PM
Was it just redundant?

Not sure 'redundant' is the right word. It's just not being used. So maybe he was using it but ended up not needing it.

I commented out the 'import sys' and the script still works.

jeric_synergy
09-24-2015, 08:45 PM
::sigh:: This sorta stuff doesn't make it easier to learn by example.

I may just cough up the $$$ and get Ryan's video series-- I'm pretty sure it'll save me a lot of dead ends. -- Although I shouldn't, since LW hasn't made me any money in a long time.

ernpchan
09-24-2015, 09:26 PM
Maybe after learning python and the LW sdk you'll make the next great script and you can sell that.

Starting with a basic understanding of python would help. There's plenty of free training for that.

jeric_synergy
09-24-2015, 10:01 PM
Python per se is not the issue: the interface to the lwsdk most certainly is.

Even the helpful explanations are painful: https://www.youtube.com/watch?v=aaJi2CfpoAM

clintonman
09-25-2015, 08:55 AM
The thing I use it for most is to automatically open the console and print a message with red text. The ordinary print won't automatically open the console.


if self._firstFrame == 999999 or self._lastFrame == -999999:
print >>sys.stderr,'Invalid frame range.'
return lwsdk.AFUNC_OK

ernpchan
09-25-2015, 09:49 AM
The thing I use it for most is to automatically open the console and print a message with red text. The ordinary print won't automatically open the console.


if self._firstFrame == 999999 or self._lastFrame == -999999:
print >>sys.stderr,'Invalid frame range.'
return lwsdk.AFUNC_OK

Ah nice tip. I open the console in my scripts.

clintonman
09-25-2015, 12:16 PM
A little off topic but a more direct way to open and clear the console



lwsdk.LWPCoreConsole().show()
lwsdk.LWPCoreConsole().clear()

ernpchan
09-25-2015, 01:14 PM
A little off topic but a more direct way to open and clear the console



lwsdk.LWPCoreConsole().show()
lwsdk.LWPCoreConsole().clear()


Yep, just remember to remove/comment those out when you publish your script. :D

jeric_synergy
09-28-2015, 03:51 PM
Clintonman, just thought you'd like to know I'm snagging this and using it today.

The slowly growing corpus of techniques in this sub-forum is very useful. I've been intending for a long time to gather up Celshader's code fragments into one document, but it strikes me that maybe someone already did. Anybody?


A little off topic but a more direct way to open and clear the console



lwsdk.LWPCoreConsole().show()
lwsdk.LWPCoreConsole().clear()

ernpchan
09-28-2015, 04:01 PM
I've been intending for a long time to gather up Celshader's code fragments into one document, but it strikes me that maybe someone already did. Anybody?

Not that I know of.