Python - Checking For Attributes

I believe Python has a method/function that checks to see if a Class has a specific attribute, but I can’t remember what it was.

Can anyone refresh my memory, please?

hasattr(, )?

pyref.infogami.com/hasattr

Thanks. It’s like the getvalue one, but I wasn’t sure if it was hasattr or hasattribute.

Might was well show a screenshot so this post isn’t an entire waste.

I’m not working on visuals at all, it’s all about code right now. I’m currently developing the GUI.

Uploaded with ImageShack.us

An alternative to hasattr() is

"attr" in dir(obj)

e.g.:

if "fire" in dir(player): player.fire()

Beside that it’s considered better style to make sure the expected attribute simply is there.

Creating Charactor Options Box -