Reputation: 139
Is there a way to get is the method called from IDLE/python shell?
For example:
def print_in_console():
if called_from_python_shell:
print('Called from console')
...do other stuff later
Upvotes: 3
Views: 30
Reputation: 267
The only feasible (easy) way I can see of doing this is by passing an argument / parameter to the function you're calling.
def function (foo, bar, called_from):
print (called_from)
*** do stuff with foo and bar ***
Upvotes: 2