adding attributes to a function, from within the function

From: Fernando Rodriguez (frr_at_easyjob.net)
Date: 10/31/03


Date: Fri, 31 Oct 2003 17:05:21 +0100

Hi,

What's the syntax to add an attribute to a function form the function body?

For example, instead of doing:
def fn():
   return 1
fn.error = "Error message"
print fn.error

I'd like to do something like this:

def fn():
  error = "Error message"
  return 1

print fn.error

How can I do this? O:-)

TIA



Relevant Pages