Getting the dependencies of a function from a library

Juergen Brendel juergen at brendel.com
Tue Apr 21 00:58:23 EDT 2020


Hello!

Not sure what's vague about the question, I think it was pretty clear.

Imagine this:

>>> import requests
>>>
>>> magic_function(requests.get)
..... prints big output of all other functions and libraries used by 
..... requests.get, plus all the functions used by those functions, 
..... etc. Maybe in some kind of tree representation...


But realistically, I think in Python that's quite difficult to do
reliably in a static manner, considering how you can dynamically change
all sorts of things at run time.

It might be more realistic to do this at run-time, using a dynamically
created call-graph. If you Google for "python call graph" you'll get
numerous hits. This is one of the top ones, to give you an idea of what
kind of output you can expect:

https://pycallgraph.readthedocs.io/en/master/

This call graph will only show the code that was actually called,
though, not all the code (and attributes for that matter) that COULD
conceivably be used under some other circumstances.

Nevertheless, it's a good start to see what your code relies on when
under use.


Juergen



On Mon, 2020-04-20 at 23:50 -0400, Bob Gailer wrote:
> For me the question is a little vague.
> 
> What do you mean by Library?
> 
> Could you give us a simple example of the input and the output?
> 
> It's possible to interpret your question as an assessment of your
> skill
> level. We know nothing about your skill level.
> 
> It's possible to interpret your question as to whether or not this is
> a
> turing complete problem.
> 
> If you succeed in coming up with a sample input and output then how
> about
> trying to write a program to process that input to get that output.
> Post
> those results to this list and we'll see what we can do to help you.
> 
> Bob gailer
> 
> On Apr 20, 2020 6:18 PM, "elisha hollander" <just4now666666 at gmail.com
> >
> wrote:
> 
> > I have a python library with a function.
> > This function call some other functions, classes and variable from
> > the
> > library (and those functions and classes call other ones, etc)...
> > Can I automatically create a file with all of the dependencies (and
> > nothing
> > else)?
> > (Already posted on stack overflow with no answer)
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 



More information about the Python-list mailing list