1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

inspectの実験

Last updated at Posted at 2012-05-10
import inspect
def call_1():
	sample = inspect.stack(1)[1]
	file_name = sample[1]
	line_num = sample[2]
	method_name = sample[3]
	format_mes = "File:%s Line:%s Method:%s"
	res = format_mes % (file_name, line_num, method_name)
	print res
	

def call_2():
	call_1()
	
def call_3():
	call_2()

# Example
print "--------------------"	
call_2()
print "--------------------"
call_3()
	
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?