Questions tagged [inspect]

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

610 questions
8
votes
3 answers

How to solve chrome ERR_DISALLOWED_URL_SCHEME when opening wss protocol?

I run node cli node --inspect start/server Which start/server is a koa2 webserver. and then I got: Debugger listening on ws://127.0.0.1:9229/3323c837-cc74-4897-af12-8fccc9d709c1 I got bellow in chrome when I input ws…
pingfengafei
  • 829
  • 2
  • 8
  • 12
8
votes
2 answers

How print every line of a python script as its being executed (including the console)?

I'd like to print every line of python script as it's being executed, as well as the log from the console as every line is being executed. For example, for this script: import time print 'hello' time.sleep(3) print 'goodbye' I'd like it to…
Chris
  • 5,444
  • 16
  • 63
  • 119
8
votes
5 answers

Get method of a class in the order that it was in the code

This code: import inspect class Obj(): def c(self): return 1 def b(self): return 2 def a(self): return 3 o = Obj() for name, value in inspect.getmembers(o, inspect.ismethod): print str(value())+"…
santos82h
  • 452
  • 5
  • 15
8
votes
1 answer

Python how to get the calling function (not just its name)?

I want to write a function which returns the calling function: def foo(): return get_calling_function() #should return 'foo' function object There's numerous examples online how to get the calling function's name, but not how to get the actual…
marius
  • 1,352
  • 1
  • 13
  • 29
8
votes
1 answer

Uispy Return's Value as "?"

i am using UISpy to detect the outlook TO Address Field but uispy return the Values as "?" If it's normal text then Uispy detects correctly it's showing the To Address. the problem is when we enter any email address in To address field its…
Ravi Kanth
  • 1,182
  • 13
  • 38
7
votes
4 answers

How to prevent decompilation or inspecting python code?

let us assume that there is a big, commercial project (a.k.a Project), which uses Python under the hood to manage plugins for configuring new control surfaces which can be attached and used by Project. There was a small information leak, some part…
Helbreder
  • 882
  • 2
  • 13
  • 24
7
votes
1 answer

How to deal with limitations of "inspect.getsource" - or how to get ONLY the source of a function?

I have been playing with the inspect module from Python's standard library. The following examples work just fine (assuming that inspect has been imported): def foo(x, y): return x - y print(inspect.getsource(foo)) ... will print def foo(x,…
s-m-e
  • 3,433
  • 2
  • 34
  • 71
7
votes
3 answers

Detect if class was defined declarative or functional - possible?

Here's a simple class created declaratively: class Person: def say_hello(self): print("hello") And here's a similar class, but it was defined by invoking the metaclass manually: def say_hello(self): …
wim
  • 338,267
  • 99
  • 616
  • 750
7
votes
2 answers

Getting the source of an object defined in a Jupyter Notebook

Usually, if you want to get the source of an object, you can get it via the inspect module: import inspect inspect.getsource(MyObject) However, in a Jupyter notebook, this doesn't work: import inspect class Foo: def __init__(self, info): …
Andrew Spott
  • 3,457
  • 8
  • 33
  • 59
7
votes
1 answer

chrome devtools source not inspectable after backtick

If I stop my javascript code in a breakpoint and try to inspect certain part of the code like a variable or a function by hovering over, it gives a popup with its value like in the screenshot below: But If I use es6 template strings in my code like…
Probosckie
  • 1,585
  • 4
  • 25
  • 40
7
votes
3 answers

Inspect element without right clicking in Chrome

When I inspect html/css on a website, I usually open the chrome developers panel ctrl+shift+I → right click context menu "inspect" so I can highlight that class however, sometimes I'm trying to inspect an element that is sensitive to "right…
Vincent Tang
  • 3,758
  • 6
  • 45
  • 63
7
votes
2 answers

How do I print the variable arguments with names from previous stack?

I would like to define a log function that is called with a message followed by one or more variables to be printed out. So, something like the following: log( "Oh no, error.", x, d) log would be defined sorta like: def log( msg, *arg): # Loop…
Bitdiot
  • 1,506
  • 2
  • 16
  • 30
7
votes
1 answer

Getting method calls and their arguments from method object

Using pythons inspect module I have isolated a method object, I now need to step through the source code in the method to find calls to certain other methods and get their arguments. For example, suppose in the following class: def my_method(): …
thodic
  • 2,229
  • 1
  • 19
  • 35
6
votes
3 answers

How to find out if (the source code of) a function contains a call to a method from a specific module?

Let's say, I have a bunch of functions a, b, c, d and e and I want to find out if they call any method from the random module: def a(): pass def b(): import random def c(): import random random.randint(0, 1) def d(): import…
finefoot
  • 9,914
  • 7
  • 59
  • 102
6
votes
3 answers

KENDO UI ANGULAR inspect STYLES of POPUP element in CHROME

Consider a situation when you have for example KENDO Angular UI component... for example plain dropdown. When you click on dropdown it will show you its menu. Now you want to inspect styles of this menu or styles of one of many items in this menu.…
Pavel Franta
  • 1,273
  • 2
  • 11
  • 24