-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.0.1.py
More file actions
35 lines (25 loc) · 1.07 KB
/
Copy path8.0.1.py
File metadata and controls
35 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Тиждень 8 Задача 1
-------------------
Напишіть Python-функцію inspector, яка визначає корисну інформацію в переданом
їй об'єкті функції та створює читабельний рядок з цією інформацією в такому форматі:
Func name: {func_name}
Func docs: {func_doc_string}
Num of local variables: {num_of_local_variables}
Name of local variables: {local_variable_names}
"""
def func1():
a=10
b=20
pass
def inspector(func):
# students write your program here
func_name = func.__name__
func_doc_string = func.__doc__
num_of_local_variables = func.__code__.co_nlocals
local_variable_names = func.__code__.co_varnames
local_variable_names = ', '.join(local_variable_names)
return f"Func name: {func_name}\nFunc docs: {func_doc_string}\nNum of local variables: {num_of_local_variables}\nName of local variables: {local_variable_names}\n"
res=inspector(func1)
print(res)
print("===========================================")