Find out where a class is used throughout a program.

Azureaus lo0446 at my.bristol.ac.uk
Thu Sep 5 08:42:21 EDT 2013


On Wednesday, 4 September 2013 17:32:28 UTC+1, Azureaus  wrote:
> Hi All,
> 
> I'm fairly new to Python so please forgive me If I sound confused or include anything a bit irrelevant. I've had some great responses from this group already though so thanks.
> 
> 
> 
> I have a source file that is laid out roughly like
> 
> 
> 
> class:
> 
> class methods
> 
> methods 
> 
> init statement
> 
> class:
> 
> method
> 
> 
> 
> It doesn't seem to have a run method unlike other similar source files I have so it seems to be that this is being referenced from other files and is almost a 'utility file'.
> 
> 
> 
> To try and make this question as general as possible - is there a way of finding out / visualising where a particular class is called/used throughout a program? I need to find out the way in which these classes are being used and their typical input (and where the output from these are going) so I can have a play around and really figure out how it works. Without a run method to call, or an idea of expected input/output it's difficult. Also without some sort of trace it's difficult.
> 
> 
> 
> I spoke to colleague and was told to look into dir() method in a Python shell which I will do this evening but if anyone has any suggestions that would be great. Even better if you think this is what I'm after a quick example/use case would be even better. Or maybe I'm looking at this the wrong way and you can point me towards some docs?
> 
> Thanks for your help.

Thanks you all for your time and responses they have been a great help. The practical examples were especially helpful. I'm going to go through the suggestions and try them out to find which one is most suited but overall I feel like my understanding/knowledge of Python has increased which is really the whole point. I think I'm going to be a regular here :)



More information about the Python-list mailing list