Hello

I have a problem that I can't understand. This errror return when I try to compile:
name 'image_name' is not defined.
This is my code:

def LoadImage(image_name):
	    file_name = self.clssSnc.sprites[slf.clssSnc.stat]
	    if self.clssSnc.stat == 0:
	        file_name = self.clssSnc.spritesi[slf.clssSnc.stati]
		#carrega a imagem do cenĂ¡rio ou do personagem
        fl = None
        image_path = "sprites/" + image_name
        fl = open(image_path, 'r')
        if (image == "sonic"):
		    file_path = "sprites/" + file_name
		    fl = open(file_path, 'r')

image_name is defined as a parameter of method.
Please, can someone help me? Thanks

I think the indentation is wrong. May be it should be this

def LoadImage(image_name):
    file_name = self.clssSnc.sprites[slf.clssSnc.stat]
    if self.clssSnc.stat == 0:
        file_name = self.clssSnc.spritesi[slf.clssSnc.stati]
        #carrega a imagem do cenrio ou do personagem
    fl = None
    image_path = "sprites/" + image_name
    fl = open(image_path, 'r')
    if (image == "sonic"):
        file_path = "sprites/" + file_name
        fl = open(file_path, 'r')

Mixing tabs and spaces will give you very troublesome indentations. I recommend to stick with spaces only, since not everyone's tab settings are the same.

Somewhere in your program you have to get a value for image_name before you call your function.

I see now. My editor show me correct identation. I'll use only spaces to ident now. Thank you very much for help.

This question has already been answered. Start a new discussion instead.