Please help: 'Return' outside function error with bug script

I am new to Blender and Python and was trying to follow a tutorial in the book Blender 2.49 Scripting by Michel Anders. I was trying to write a script that would create a user interface where the user could select various aspect of an insect and the code would create a polygonal bug. However, when I copied code exactly from the book, I got an error saying “‘return’ outside function”. Here is the code I had in the text editor:


import Blender
import mymesh2

Draw = Blender.Draw
TAILSEGMENTS = Draw.Create(5)
LEGSEGMENTS = Draw.Create(2)
WINGSEGMENTS = Draw.Create(2)
EYESIZE = Draw.Create(1.0)
TAILTAPER = Draw.Create(0.9)

if not Draw.PupBlock('Add CreepyCrawly', [
('Thorax segments:'  , THORAXSEGMENTS, 2,  50, 
    'Number of thorax segments'),\   
('Tail segments:' , TAILSEGMENTS, 0,  50, 'Number of tail segments'),\
('Leg segments:' , LEGSEGMENTS,    2, 10,
    'Number of thorax segments with legs'),\  
('Wing segments:' , WINGSEGMENTS, 0,  10,
    'Number of thorax segments with wings'),\  
('Eye size:' , EYESIZE,    0.1,10, 'Size of the eyes'),\
('Tail taper:' , TAILTAPER, 0.1,10,
    Taper fraction of each tail segment'),]):  

Anybody know why I keep getting this error?

Thanks a lot



Alright. That looks a lot better now that I put code blocks in. So can anyone help me out?

python is indeention sensative. i dont think return should be indented and while i’m not fluent in python every time i see return it is followed by what to return (self alot of times)

You’re getting that error because you’re trying to use return outside a function like it says…