Kurt Bourbaki
Kurt Bourbaki

Reputation: 12596

How to find out what function I am calling

I am calling a function like this:

classifier = NaiveBayesClassifier.train(training_set)

and I would like to debug the code inside the train() function. The problem is that if I add print statements or pdb calls nothing changes.

I am importing this:

from nltk.classify.naivebayes import NaiveBayesClassifier

but even if I change something in nltk/classify/naivebayes.py nothing happens. I can also delete all the content of this file and I still have a working output. So I suppose that the function I am calling is somewhere else, but I cannot find it.

Is there a way to check where my function call is actually going? I am quite confused.

Upvotes: 0

Views: 60

Answers (1)

avichalp
avichalp

Reputation: 1120

Step in the function using pdb. use pdb.set_trace() some where before you are calling train method.

Something like this

import pdb; pdb.set_trace() classifier = NaiveBayesClassifier.train(training_set)

When you debug. Stop at the line where you are calling train method. press s to step in the function. This will take you inside the train function. From there you can debug normally.

Upvotes: 1

Related Questions