Find what is in the PYC file

These may be noobie questions, but ...

So, I have a pyc file that I need to use, but I don't have documentation. Is there any way to know which classes and functions in it and which variables they accept? I do not need to code how to run it.

thank

+3
source share
4 answers

if you paste it into your import path and import it by name, you can use dir

import foo
dir(foo)

you can also use `help '

help(foo)

. , foo. , - , python. , , , - , .


, argcount

argcount = f.func_code.co_argcount

arcount

f.func_code.co_varnames

, , , docstring, .

+4

, ; , .py .pyc.

>>> import getopt
>>> dir(getopt)
['GetoptError', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'do_longs', 'do_shorts', 'error', 'getopt', 'gnu_getopt', 'long_has_args', 'os', 'short_has_arg']
>>> type(getopt.getopt)
<type 'function'>
>>> inspect.getargspec(getopt.getopt)
ArgSpec(args=['args', 'shortopts', 'longopts'], varargs=None, keywords=None, defaults=([],))
>>> help(getopt.getopt)
Help on function getopt in module getopt:
...
+9

docstrings, , docstrings, :

foo.pyc

import foo
dir(foo)
help(foo)

If you decide that you need code, decompyle .

0
source

Source: https://habr.com/ru/post/1759955/