Problem Testing Selected Python defs in Eclipse

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  09 September 2012
Problem Testing Selected Python defs in Eclipse

When I try to execute selected code that includes a function, it won't
register the function.

I have this code in a module ( _ = space):
def process_all_textures():
_print ('Process all textures.')
_print type(process_all_textures)

def junk():

_print ('junk')
_print type(junk)

If I run the code in PyDev (Run As Python Run, Ctrl+F11), it executes

If I select any of the text and send to Maya, it executes correctly,
(after the def has been registered).

However, when I select the first 4 lines of text and execute those
lines only in PyDev (Crtl+Alt+Enter - which is Interactive Console), I
get this error:
File "<console>", line 3
SyntaxError: invalid syntax
print type(process_all_textures)
<type 'function'>

Ctrl+Alt+Enter with no text selected executes the whole module correctly.

Anyone have insight?
If animation couldn't change the world, it wouldn't be such a Micky-Mouse place.

Last edited by EightBit : 09 September 2012 at 04:05 AM.
  09 September 2012
Ok, this is what I think you may have done...

First you ran the code like you wrote it here (ie all indented ) so you function was recursive, with no limit. ie it calls itself within itself, but the interpreter simply registered the function.
Then you noticed the indentation mistake and fixed it, moving process_all_textures() out of the function definition,

def process_all_textures():
	print 'process all textures'
print type(process_all_textures)

and you ran all 4 lines again. It should have worked, but the interpreter has cached the original defintion of the function so it still errors.

Try deleting the orginal definition by doing this first

  10 October 2012
Thanks for the reply as always David:
I didn't run the function call inside the function - I just showed the wrong indentation when I added the underscores above (this is a great CG forum, but I WISH they would install a good python formatting option).
However, after a bunch more time troubleshooting, I discovered that when sending a selection to the interpreter, the selection must include at least one empty line (no tabs) below the function. Else it won't register correctly and execution as well as 'del()' will fail. Note also if not selected correctly the new definition will corrupt a previously registered function of the same name, causing the error shown above.

Glad that is solved.
The del function is good to know.
If animation couldn't change the world, it wouldn't be such a Micky-Mouse place.
  10 October 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:16 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.