I don't quite understand where imports and function definitions are visibile in a python module. Here's a simplification of my case:
from scapy.all import *
def getA():
return 0
def getB():
return getA() + 1
def getC():
code.interact(local=locals())
return 3
def main():
print getA()
print getB()
print getC()
exit()
if __name__ == '__main__':
main()
Now, everything goes smoothly until I reach function getC
and a command prompt appears, a lot of what I should see is missing.
Why does this happen? What am I getting wrong?
What is Importing? Importing refers to allowing a Python file or a Python module to access the script from another Python file or module. You can only use functions and properties your program can access. For instance, if you want to use mathematical functionalities, you must import the math package first.
You need to tell python to first import that module in your code so that you can use it. If you have your own python files you want to import, you can use the import statement as follows: >>> import my_file # assuming you have the file, my_file.py in the current directory.
As I wrote in a comment above, the solution is:
code.interact(local=dict(globals(), **locals()))
(taken here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With