Package: nitvars
# nitvarsPython variables v2 packagePython version 3 or lateradd new version of globals, localsglobals fixadd tracer, scaner frame infoadd exec v2 = multiline exec and return resultadd multiline  lambda  lambda x,y:e2('x=x+1;print(x);x+y')for see and test all functions run nitvars_test.py  or "py -m nitvars" orfrom nitvars.nitvars_test import *main()Select test ['0=testglobals2', '1=testlocals2', '2=exec2test', '3=lambda2test', '4=testscaner', '5=tracertest', '6=callhelptest', 'all=all tests']:######## testglobals2Now get testvar. testvar in globals!var "testvar" in simple globals()=NOT FOUND!Not found "testvar" in levels {'nitvars.nitvars', '__main__'}var "testvar" in globals2()=NoneNot found "testvar" in levels {'module'}var "testvar" in realglobals()=Nonetestvar in [level:id]: NoneWhy?  globals() find globals only in this script(in nitvars.py..)Now set testvar with "global testvar"var "testvar" in simple globals()=SET OK!var "testvar" in globals2()=SET OK!Not found "testvar" in levels {'module'}var "testvar" in realglobals()=Nonetestvar in [level:id]: {'nitvars.nitvars': 2538507971952}Why?  global x set globals only in this script(in nitvars.py..)Now set testvar2 with "globals()[testvar]"var "testvar" in simple globals()=SET OK!2var "testvar" in globals2()=SET OK!2Not found "testvar" in levels {'module'}var "testvar" in realglobals()=Nonetestvar in [level:id]: {'nitvars.nitvars': 2538507972016}Why?  globals() set globals only in this script(in nitvars.py..)Now set testvar2 with nitvars "globals2()[testvar]"var "testvar" in simple globals()=SET OK!3var "testvar" in globals2()=SET OK!3var "testvar" in realglobals()=SET OK!3testvar in [level:id]: {'nitvars.nitvars': 2538507972144, '__main__': 2538507972144}Why?  globals2() is real globals, globals() is ...Press Enter to continue..q=exit######## testlocals2locals = (2, 3, 1)simple locals=> {}(is empty!) locals2=> {'x': 2, 'y': 3} + ^up level=globals. you can get/set/del, create vars in locals()dictlocals set in other nested function! locals = {'x': 700, 'y': 70} + global z=7.  result= 771) #=777Press Enter to continue..q=exit######## exec2testthis code run in exec2and return result of x=x+50 , x+y200Press Enter to continue..q=exit######## lambda2testtest multiline lambdas!This code run multiline lambda => x,y:e2('x=x+5;x+y')35Press Enter to continue..q=exit######## testscanerTest scan other objects andframes. Scan this frame:Scan results:name: testscanerall: filename: C:\Users\nikos\Desktop\py\nitvars\nitvars_test.pyline: 44name: testscanerlocals: {'x': 1, 'y': 2, 'z': 3}module: nitvars.nitvars_testcode: def testscaner(x=1,y=2):print('Test scan other objects andframes. Scan this frame:')z=3includescaner()comment: #test commargs_str: (x=1,y=2)path: nitvars.nitvars_test._run_code.<module>.main.testscanerobject: Nonesignature: line 44[level:3]: nitvars.nitvars_test._run_code.<module>.main.testscaner(x=1,y=2) {'x': 1, 'y': 2, 'z': 3}Press Enter to continue..q=exit######## tracertestTEST TRACE DECORATOR>>>CALL: line 57[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.decfunc(xx,x=120) {'xx': 80, 'x': 120}### RETURN: line 59[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.decfunc(xx,x=120) {'xx': 80, 'x': 120} ==> 200 [<class 'int'>]Trace results=>>calls=>[line 57[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.decfunc(xx,x=120) {'xx': 80, 'x': 120}] returns=>[200]TEST TRACE DECORATOR 2>>>CALL: line 62[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.testfunc(xx,x=170) {'xx': 80, 'x': 170}### RETURN: line 63[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.testfunc(xx,x=170) {'xx': 80, 'x': 170} ==> 250 [<class 'int'>]Trace results=>>calls=>[line 62[level:5]: nitvars.nitvars_test._run_code.<module>.main.tracertest.trace_func.testfunc(xx,x=170) {'xx': 80, 'x': 170}] returns=>[250]TEST TRACE WITH>>>CALL: line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 270, 'x': 170}### RETURN: line 63[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 270, 'x': 170} ==> 440 [<class 'int'>]>>>CALL: line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 370, 'x': 170}### RETURN: line 63[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 370, 'x': 170} ==> 540 [<class 'int'>]Trace results=>>calls=>[line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 270, 'x': 170}, line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 370, 'x': 170}] returns=>[440, 540]TEST TRACE GLOBAL TRACE ON>>>CALL: line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 470, 'x': 170}### RETURN: line 63[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 470, 'x': 170} ==> 640 [<class 'int'>]>>>CALL: line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 570, 'x': 170}### RETURN: line 63[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 570, 'x': 170} ==> 740 [<class 'int'>]Trace results=>>calls=>[line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 270, 'x': 170}, line 62[level:4]: nitvars.nitvars_test._run_code.<module>.main.tracertest.testfunc(xx,x=170) {'xx': 370, 'x': 170}] returns=>[440, 540]TEST TRACE str combo returns Demo version of use tracer<div id="linksblock"></div>Press Enter to continue..q=exit######## callhelptesttest callhelp decorator run myfunc(x,y,z=7) as myfunc() . x and y not definedhelp call func if args not definedЗапуск функции myfunc(x, y, z=7)Введите параметр "x"("#q" для отмены запуска)111Введите параметр "y"("#q" для отмены запуска)222340Press Enter to continue..q=exit