0

I have created the following variable, which captures the function from a Point object I created:

j = i.getfunction()
print(j)

The print(j) outputs something like this whenever it's called:

<function draw_H at 0x1057ce268>

What I want to do is find out if the item attached to the variable contains certain words. For instance, using the print(j) output above, I want to find out if j contains draw_H, like so:

if j contains draw_H:
    # Run this code

How would I do this? Specifically, how would I find out if an item attached to a variable contains a certain word? Any help is greatly appreciated!

R. Kap
  • 599
  • 1
  • 10
  • 33

1 Answers1

1

Use the __name__ attribute:

print (j.__name__)

to test for a substring do:

if "draw_H" in j.__name__:
    <do stuff>
gariepy
  • 3,576
  • 6
  • 21
  • 34