Questions tagged [inspect]

DO NOT USE! THIS IS AMBIGUOUS. You might be looking for [web-inspector].

610 questions
4
votes
2 answers

How do I infer the class to which a @staticmethod belongs?

I am trying to implement infer_class function that, given a method, figures out the class to which the method belongs. So far I have something like this: import inspect def infer_class(f): if inspect.ismethod(f): return f.im_self if…
Pavel Repin
  • 30,663
  • 1
  • 34
  • 41
4
votes
3 answers

What is the benefit of using YAML?

When someone mentions the idea of saving information to external files by writing the inspect output and loading it via eval, I see that many people will criticize that idea and instead recommend using YAML. What is the problem of writing the output…
sawa
  • 165,429
  • 45
  • 277
  • 381
4
votes
4 answers

"Inspect Element" tool for Java UI

I was looking for tool on Java that does the same (similar) functionality of "inspect element" of "Google Chrome". Does anyone has information whether this is available and how it can be implemented? The question refers to cases when you have the…
asterix55
  • 93
  • 1
  • 2
  • 8
4
votes
4 answers

Groovy inspect() handle dollar sign($)

below code can not run def map = [name:"Test :: ( %2f %25 \$ * & ! @ # ^)"] String s = map.inspect() println Eval.me(s) get error: Script1.groovy: 1: illegal string body character after dollar sign; solution: either escape a literal dollar sign…
Xilang
  • 1,513
  • 3
  • 18
  • 36
4
votes
3 answers

How to locate .php code and file on the server when inspecting elements from an internet browser?

When I inspect an element of my webpage using Firebug, I cannot identify which .php code it using and on which php file I can find this code on from the server. Is there any other way to locate pieces of php codes from a browser? Many…
Arthur Mamou-Mani
  • 2,303
  • 10
  • 43
  • 69
4
votes
3 answers

How to locate the file a code object come from?

I need to know where a code object comes from ; its module. So I (naively) tried : os.path.abspath(code.co_filename) But that may or may not work, (I think it's because abspath depends on cwd) Any way to get the full path of a code object's…
dugres
  • 12,613
  • 8
  • 46
  • 51
4
votes
1 answer

How to get caller name inside pytest fixture?

Assume we have: @pytest.fixture() def setup(): print('All set up!') return True def foo(setup): print('I am using a fixture to set things up') setup_done=setup I'm looking for a way to get to know caller function name (in this…
Mgasi
  • 43
  • 4
4
votes
1 answer

Debugging JavaScript code that uses ES6 Modules

TL;DR: How can I access variables/functions/names that are defined in ES Modules from the debugger? More context: I'm a relatively experienced JavaScript programmer, but new to Modules. I've followed the tutorial at MDN here:…
4
votes
1 answer

Python `inspect.Signature` shows all defined positional arguments as `ParameterKind.POSITIONAL_OR_KEYWORD`

I had the impression that you could use the inspect.Signature function to retrieve and distinguish between positional and keyword arguments. However this does not seem to be the case: def foo(a,b,c, t=3, q=5): print(a,b,c,t,q) [(u, u.kind) for…
lurscher
  • 25,930
  • 29
  • 122
  • 185
4
votes
1 answer

Access the locals available in the previous stack frame

I have a debug context manager where I would like to access the locals() at the time the context manager was initiated, without giving the locals as an argument. Is this possible? I would like to do this in the general case, so that my Debug context…
The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
4
votes
0 answers

Airflow apply_defaults decorator reports Argument is required

I recently ran into this nasty error where Airflow's apply_defaults decorator is throwing following stack-trace (my **kwargs do contain job_flow_id) File "", line 219, in _call_with_frames_removed File…
y2k-shubham
  • 10,183
  • 11
  • 55
  • 131
4
votes
2 answers

Workaround for __getattr__ special method breaking inspect.getmembers() in Python 3.x

The inspect.getmembers function breaks when used with a class that defines the __getattr__ method (in Python 3.x): import inspect class C: def __getattr__(self, name): def wrapper(): print("For MCVE purposes, this does…
Nikola Benes
  • 2,372
  • 1
  • 20
  • 33
4
votes
1 answer

Obtain Python docstring of arbitrary script file

I am writing a module that requires the docstring of the calling script. Thus far I have managed to obtain the filename of the calling script using import inspect filename = inspect.stack()[1].filename The docstring can be found inside the calling…
Octaviour
  • 745
  • 6
  • 18
4
votes
1 answer

HTML Render with inspect element functionality? HOW TO C#

I want to do a HTML Render that shows a HTML Document, not necessary an online webpage. Then when I click over a HTML Control, it shows only the HTML where I clicked. The real intention is to get the xpath from the root element to the selected TAG.
Johans
  • 49
  • 1
  • 3
4
votes
1 answer

Source info missing from python classes loaded with module_from_spec

I am trying to use Python's introspection module inspect to retrieve the source code for live objects which have been loaded into the scope using the module_from_spec function of importlib.util. Attempts to use inspect.getsource() on either the…
R J
  • 4,473
  • 2
  • 22
  • 29