python - return outside function, or unexpected indent -


i have this:

if colorkey not none:         if colorkey -1:          colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, rleaccel) return image, image.get_rect() 

it tells me "return" outside function.

when change this:

if colorkey not none:         if colorkey -1:          colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, rleaccel)     return image, image.get_rect() 

it tells me there unexpected indent. how around this?

in python, scopes defined same level of indentation instead of braces (i.e. {}) in other languages.

if write function, need ensure function body @ same level of indentation - same amount of spaces or same amount of tabs (mixing spaces , tabs can result in real mess).

in case, correct indentation similar (i not know exactly, because didn't post code whole function):

def function(): <indent>if colorkey not none: <indent><indent>if colorkey -1: <indent><indent><indent>colorkey = image.get_at((0,0)) <indent>image.set_colorkey(colorkey, rleaccel) <indent>return image, image.get_rect() 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -