2

Doing a math function of the type def.

def integral_error(integral,f):
    ------stufff-------
    print integral

gives something like: '<function simpsons at 0xb7370a74>'

is there a way to get just simpsons without string manipulations? ie just the function name?

1
  • Well you got a bunch of answers quickly, probably because of a catchy title, but you really could have given a better description of the problem and what exactly you're looking for. Commented Oct 25, 2012 at 20:00

3 Answers 3

8

You can use:

integral.func_name

Or:

integral.__name__

Though, they are exactly equivalent. According to docs:

__name__ is Another way of spelling func_name

Here's a sample code:

>>> def f():
    pass

>>> f.__name__
'f'
>>> f.func_name
'f'
>>> 
Sign up to request clarification or add additional context in comments.

1 Comment

You might want to add that according to the docs, func_name and __name__ are completely equivalent.
3

You can do this by using integral_error.__name__.

1 Comment

the OP wanted to have the name of integral, i think
2

You can use __name__ like so integral.__name__

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.