alexmojaki / snoop

A powerful set of Python debugging tools, based on PySnooper
MIT License
1.28k stars 35 forks source link

Filter variables to output when using `with snoop:` ? #44

Closed Eliazar225 closed 3 years ago

Eliazar225 commented 3 years ago

I tried to run "with snoop" on a part of my code and it printed this in the console

I wish there's some way to filter the variables to output when using "with snoop:" so I can remove some unnecessary output such as "object variables" and "class instance"

This is the part code I run with "with snoop":

with snoop:
    for files in sourcefiles:
        for file_type in images:
            if files.endswith(file_type):
                path = os.path.join(dir, files)
                for element in result:
                    if " " in element:
                        for element in element.split(" "):
                            filter(element)
                    else:
                        filter(element)
                fil_result.append("\n\n")
                per_picture.append(fil_result)
                fil_result = []

Then this is the result to the console:

07:17:12.34 >>> Enter with block in <module> in File "D:\OCR\New folder\safe prototype gui.py", line 347
07:17:12.34 ...... __name__ = '__main__'
07:17:12.34 ...... __doc__ = None
07:17:12.34 ...... __package__ = None
07:17:12.34 ...... __loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x0000021346836CD0>
07:17:12.34 ...... __spec__ = None
07:17:12.34 ...... __annotations__ = {}
07:17:12.34 ...... __builtins__ = <module 'builtins' (built-in)>
07:17:12.34 ...... __file__ = 'D:\\OCR\\New folder\\safe prototype gui.py'
07:17:12.34 ...... __cached__ = None
07:17:12.34 ...... QApplication = <class 'PyQt5.QtWidgets.QApplication'>
07:17:12.34 ...... QWidget = <class 'PyQt5.QtWidgets.QWidget'>
07:17:12.34 ...... QFileDialog = <class 'PyQt5.QtWidgets.QFileDialog'>
07:17:12.34 ...... QLineEdit = <class 'PyQt5.QtWidgets.QLineEdit'>
07:17:12.34 ...... QComboBox = <class 'PyQt5.QtWidgets.QComboBox'>
07:17:12.34 ...... QTableWidgetSelectionRange = <class 'PyQt5.QtWidgets.QTableWidgetSelectionRange'>
07:17:12.34 ...... QColor = <class 'PyQt5.QtGui.QColor'>
07:17:12.34 ...... QFont = <class 'PyQt5.QtGui.QFont'>
07:17:12.34 ...... QStandardItemModel = <class 'PyQt5.QtGui.QStandardItemModel'>
07:17:12.34 ...... QStandardItem = <class 'PyQt5.QtGui.QStandardItem'>
07:17:12.34 ...... uic = <module 'PyQt5.uic' from 'C:\\Users\\Eliaz\\AppD...39\\lib\\site-packages\\PyQt5\\uic\\__init__.py'>
07:17:12.34 ...... QtWidgets = <module 'PyQt5.QtWidgets' from 'C:\\Users\\Eliaz...hon39\\lib\\site-packages\\PyQt5\\QtWidgets.pyd'>
07:17:12.34 ...... Qt = <class 'PyQt5.QtCore.Qt'>
07:17:12.34 ...... QSortFilterProxyModel = <class 'PyQt5.QtCore.QSortFilterProxyModel'>
07:17:12.34 ...... QtCore = <module 'PyQt5.QtCore' from 'C:\\Users\\Eliaz\\A...Python39\\lib\\site-packages\\PyQt5\\QtCore.pyd'>
07:17:12.34 ...... QtGui = <module 'PyQt5.QtGui' from 'C:\\Users\\Eliaz\\Ap...\Python39\\lib\\site-packages\\PyQt5\\QtGui.pyd'>
07:17:12.34 ...... easyocr = <module 'easyocr' from 'C:\\Users\\Eliaz\\AppDat...hon39\\lib\\site-packages\\easyocr\\__init__.py'>
07:17:12.34 ...... sys = <module 'sys' (built-in)>
07:17:12.34 ...... os = <module 'os' from 'C:\\Users\\Eliaz\\AppData\\Local\\Programs\\Python\\Python39\\lib\\os.py'>
07:17:12.34 ...... ic = <icecream.icecream.IceCreamDebugger object at 0x000002135FCC2940>
07:17:12.34 ...... snoop = <class 'snoop.configuration.Config.__init__.<locals>.ConfiguredTracer'>
07:17:12.34 ...... ps = <module 'pysnooper' from 'C:\\Users\\Eliaz\\AppD...n39\\lib\\site-packages\\pysnooper\\__init__.py'>
07:17:12.34 ...... DialogApp = <class '__main__.DialogApp'>
07:17:12.34 ...... MyApp = <class '__main__.MyApp'>
07:17:12.34 ...... filter = <function filter at 0x000002134687DF70>
07:17:12.34 ...... MyAppGui = <function MyAppGui at 0x000002135FE6EF70>
07:17:12.34 ...... app = <PyQt5.QtWidgets.QApplication object at 0x000002135FE6F040>
07:17:12.34 ...... demo = <__main__.DialogApp object at 0x000002135FE6F0D0>
07:17:12.34 ...... replaces = {'k': 'rep', 'as': 'like'}
07:17:12.34 ...... len(replaces) = 2
07:17:12.34 ...... rep = <_io.TextIOWrapper name='D:\\OCR\\dict.txt' mode='r' encoding='cp1252'>
07:17:12.34 ...... line = 'earth\n'
07:17:12.34 ...... key = 'as'
07:17:12.34 ...... value = 'like'
07:17:12.34 ...... ignores = {'earth', 'lithosphere', 'The', 'and', 'properties', 'Layers', 'that', 'a', 'categorized', 'temperature,', ...}
07:17:12.34 ...... len(ignores) = 23
07:17:12.34 ...... ign = <_io.TextIOWrapper name='D:\\OCR\\ignores.txt' mode='r' encoding='cp1252'>
07:17:12.34 ...... val = 'earth'
07:17:12.34 ...... textfile = <_io.TextIOWrapper name='D:\\OCR\\ignore.txt' mode='w' encoding='cp1252'>
07:17:12.34 ...... images = ['.tiff', '.gif', '.png', '.eps', '.bmp', '.jpg', '.jpf', '.jpeg', '.ppm']
07:17:12.34 ...... len(images) = 9
07:17:12.34 ...... delete = set()
07:17:12.34 ...... unknown_words = set()
07:17:12.34 ...... fil_result = []
07:17:12.34 ...... result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', ..., 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
07:17:12.34 ...... len(result) = 26
07:17:12.34 ...... list_of_strings_from_textedit = []
07:17:12.34 ...... per_picture = []
07:17:12.34 ...... dir = 'D:\\OCR\\test'
07:17:12.34 ...... sourcefiles = ['2021-09-15 08_06_48-(2) Facebook - Vivaldi.jpg', '2021-09-15 08_10_38-(2) Facebook - Vivaldi.jpg', 'textfile.txt']
07:17:12.34 ...... len(sourcefiles) = 3
07:17:12.34  348 |     for files in sourcefiles:
07:17:12.34 .......... files = '2021-09-15 08_06_48-(2) Facebook - Vivaldi.jpg'
07:17:12.34  349 |         for file_type in images:
07:17:12.34 .............. file_type = '.tiff'
07:17:12.34  350 |             if files.endswith(file_type):
07:17:12.34  349 |         for file_type in images:
07:17:12.34 .............. file_type = '.gif'
07:17:12.34  350 |             if files.endswith(file_type):
07:17:12.35  349 |         for file_type in images:
07:17:12.35 .............. file_type = '.png'
07:17:12.35  350 |             if files.endswith(file_type):
07:17:12.35  349 |         for file_type in images:
07:17:12.35 .............. file_type = '.eps'
07:17:12.35  350 |             if files.endswith(file_type):
07:17:12.35  349 |         for file_type in images:
07:17:12.35 .............. file_type = '.bmp'
07:17:12.35  350 |             if files.endswith(file_type):
07:17:12.35  349 |         for file_type in images:
07:17:12.35 .............. file_type = '.jpg'
07:17:12.35  350 |             if files.endswith(file_type):
07:17:12.35  351 |                 path = os.path.join(dir, files)
07:17:12.35 ...................... path = 'D:\\OCR\\test\\2021-09-15 08_06_48-(2) Facebook - Vivaldi.jpg'
07:17:12.35 ...................... len(path) = 58
07:17:12.35  355 |                 for element in result:
07:17:12.35 ...................... element = 'a'
07:17:12.35  356 |                     if " " in element:
07:17:12.35  360 |                         filter(element)
07:17:12.35 .............................. unknown_words = {'a'}
07:17:12.35 .............................. len(unknown_words) = 1
07:17:12.35 .............................. fil_result = ['a', ' ']
07:17:12.35 .............................. len(fil_result) = 2
07:17:12.35 .............................. __warningregistry__ = {'version': 22}
07:17:12.35 .............................. len(__warningregistry__) = 1
07:17:12.35  355 |                 for element in result:
07:17:12.35 ...................... element = 'b'
07:17:12.35  356 |                     if " " in element:
07:17:12.35  360 |                         filter(element)
07:17:12.35 .............................. unknown_words = {'b', 'a'}
07:17:12.35 .............................. len(unknown_words) = 2
07:17:12.35 .............................. fil_result = ['a', ' ', 'b', ' ']
07:17:12.35 .............................. len(fil_result) = 4
07:17:12.35  355 |                 for element in result:
07:17:12.35 ...................... element = 'c'
07:17:12.35  356 |                     if " " in element:
07:17:12.35  360 |                         filter(element)
07:17:12.35 .............................. unknown_words = {'b', 'a', 'c'}
07:17:12.35 .............................. len(unknown_words) = 3
07:17:12.35 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ']
07:17:12.35 .............................. len(fil_result) = 6
07:17:12.35  355 |                 for element in result:
07:17:12.36 ...................... element = 'd'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.36 .............................. unknown_words = {'b', 'a', 'c', 'd'}
07:17:12.36 .............................. len(unknown_words) = 4
07:17:12.36 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ']
07:17:12.36 .............................. len(fil_result) = 8
07:17:12.36  355 |                 for element in result:
07:17:12.36 ...................... element = 'e'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.36 .............................. unknown_words = {'b', 'c', 'd', 'a', 'e'}
07:17:12.36 .............................. len(unknown_words) = 5
07:17:12.36 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ']
07:17:12.36 .............................. len(fil_result) = 10
07:17:12.36  355 |                 for element in result:
07:17:12.36 ...................... element = 'f'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.36 .............................. unknown_words = {'b', 'c', 'd', 'a', 'f', 'e'}
07:17:12.36 .............................. len(unknown_words) = 6
07:17:12.36 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ']
07:17:12.36 .............................. len(fil_result) = 12
07:17:12.36  355 |                 for element in result:
07:17:12.36 ...................... element = 'g'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.36 .............................. unknown_words = {'b', 'c', 'd', 'a', 'g', 'f', 'e'}
07:17:12.36 .............................. len(unknown_words) = 7
07:17:12.36 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ']
07:17:12.36 .............................. len(fil_result) = 14
07:17:12.36  355 |                 for element in result:
07:17:12.36 ...................... element = 'h'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.36 .............................. unknown_words = {'b', 'c', 'd', 'a', 'g', 'f', 'h', 'e'}
07:17:12.36 .............................. len(unknown_words) = 8
07:17:12.36 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ', 'h', ' ']
07:17:12.36 .............................. len(fil_result) = 16
07:17:12.36  355 |                 for element in result:
07:17:12.36 ...................... element = 'i'
07:17:12.36  356 |                     if " " in element:
07:17:12.36  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'c', 'd', 'a', 'i', 'g', 'f', 'h', 'e'}
07:17:12.38 .............................. len(unknown_words) = 9
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ', 'h', ' ', 'i', ' ']
07:17:12.38 .............................. len(fil_result) = 18
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'j'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'c', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'e'}
07:17:12.38 .............................. len(unknown_words) = 10
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'g', ' ', 'h', ' ', 'i', ' ', 'j', ' ']
07:17:12.38 .............................. len(fil_result) = 20
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'k'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'k', 'c', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'e'}
07:17:12.38 .............................. len(unknown_words) = 11
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'h', ' ', 'i', ' ', 'j', ' ', 'k', ' ']
07:17:12.38 .............................. len(fil_result) = 22
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'l'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'k', 'c', 'l', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'e'}
07:17:12.38 .............................. len(unknown_words) = 12
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'l', ' ']
07:17:12.38 .............................. len(fil_result) = 24
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'm'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'k', 'c', 'l', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'm', 'e'}
07:17:12.38 .............................. len(unknown_words) = 13
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'j', ' ', 'k', ' ', 'l', ' ', 'm', ' ']
07:17:12.38 .............................. len(fil_result) = 26
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'n'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.38 .............................. unknown_words = {'b', 'k', 'c', 'l', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'n', 'm', 'e'}
07:17:12.38 .............................. len(unknown_words) = 14
07:17:12.38 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'k', ' ', 'l', ' ', 'm', ' ', 'n', ' ']
07:17:12.38 .............................. len(fil_result) = 28
07:17:12.38  355 |                 for element in result:
07:17:12.38 ...................... element = 'o'
07:17:12.38  356 |                     if " " in element:
07:17:12.38  360 |                         filter(element)
07:17:12.40 .............................. unknown_words = {'b', 'k', 'c', 'l', 'd', 'a', 'i', 'g', 'f', 'j', 'h', 'n', 'm', 'e', 'o'}
07:17:12.40 .............................. len(unknown_words) = 15
07:17:12.40 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'l', ' ', 'm', ' ', 'n', ' ', 'o', ' ']
07:17:12.40 .............................. len(fil_result) = 30
07:17:12.40  355 |                 for element in result:
07:17:12.40 ...................... element = 'p'
07:17:12.40  356 |                     if " " in element:
07:17:12.40  360 |                         filter(element)
07:17:12.40 .............................. unknown_words = {'b', 'k', 'c', 'l', 'd', 'p', 'a', 'i', 'g', 'f', 'j', 'h', 'n', 'm', 'e', 'o'}
07:17:12.40 .............................. len(unknown_words) = 16
07:17:12.40 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'm', ' ', 'n', ' ', 'o', ' ', 'p', ' ']
07:17:12.40 .............................. len(fil_result) = 32
07:17:12.40  355 |                 for element in result:
07:17:12.40 ...................... element = 'q'
07:17:12.40  356 |                     if " " in element:
07:17:12.40  360 |                         filter(element)
07:17:12.40 .............................. unknown_words = {'b', 'k', 'c', 'q', 'l', 'd', 'p', 'a', 'i', 'g', 'f', 'j', 'h', 'n', 'm', 'e', 'o'}
07:17:12.40 .............................. len(unknown_words) = 17
07:17:12.40 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'n', ' ', 'o', ' ', 'p', ' ', 'q', ' ']
07:17:12.40 .............................. len(fil_result) = 34
07:17:12.40  355 |                 for element in result:
07:17:12.40 ...................... element = 'r'
07:17:12.40  356 |                     if " " in element:
07:17:12.40  360 |                         filter(element)
07:17:12.40 .............................. unknown_words = {'b', 'k', 'c', 'q', 'l', 'd', 'r', 'p', 'a', 'i', 'g', 'f', 'j', 'h', 'n', 'm', 'e', 'o'}
07:17:12.40 .............................. len(unknown_words) = 18
07:17:12.40 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'o', ' ', 'p', ' ', 'q', ' ', 'r', ' ']
07:17:12.40 .............................. len(fil_result) = 36
07:17:12.40  355 |                 for element in result:
07:17:12.40 ...................... element = 's'
07:17:12.40  356 |                     if " " in element:
07:17:12.40  360 |                         filter(element)
07:17:12.41 .............................. unknown_words = {'b', 'k', 'd', 'g', 'f', 'j', 'n', 'r', 'p', 'a', 'e', 'c', 'l', 's', 'i', 'h', 'o', 'q', 'm'}
07:17:12.41 .............................. len(unknown_words) = 19
07:17:12.41 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'p', ' ', 'q', ' ', 'r', ' ', 's', ' ']
07:17:12.41 .............................. len(fil_result) = 38
07:17:12.41  355 |                 for element in result:
07:17:12.41 ...................... element = 't'
07:17:12.41  356 |                     if " " in element:
07:17:12.41  360 |                         filter(element)
07:17:12.41 .............................. unknown_words = {'b', 'k', 'd', 'g', 'f', 'j', 'n', 'r', 'p', 'a', 't', 'e', 'c', 'l', 's', 'i', 'h', 'o', 'q', ...}
07:17:12.41 .............................. len(unknown_words) = 20
07:17:12.41 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'q', ' ', 'r', ' ', 's', ' ', 't', ' ']
07:17:12.41 .............................. len(fil_result) = 40
07:17:12.41  355 |                 for element in result:
07:17:12.41 ...................... element = 'u'
07:17:12.41  356 |                     if " " in element:
07:17:12.41  360 |                         filter(element)
07:17:12.41 .............................. len(unknown_words) = 21
07:17:12.41 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'r', ' ', 's', ' ', 't', ' ', 'u', ' ']
07:17:12.41 .............................. len(fil_result) = 42
07:17:12.41  355 |                 for element in result:
07:17:12.41 ...................... element = 'v'
07:17:12.41  356 |                     if " " in element:
07:17:12.41  360 |                         filter(element)
07:17:12.41 .............................. unknown_words = {'b', 'k', 'd', 'g', 'f', 'j', 'n', 'v', 'r', 'p', 'a', 't', 'e', 'c', 'l', 's', 'i', 'h', 'o', ...}
07:17:12.41 .............................. len(unknown_words) = 22
07:17:12.41 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 's', ' ', 't', ' ', 'u', ' ', 'v', ' ']
07:17:12.41 .............................. len(fil_result) = 44
07:17:12.41  355 |                 for element in result:
07:17:12.42 ...................... element = 'w'
07:17:12.42  356 |                     if " " in element:
07:17:12.42  360 |                         filter(element)
07:17:12.42 .............................. unknown_words = {'b', 'k', 'd', 'w', 'g', 'f', 'j', 'n', 'v', 'r', 'p', 'a', 't', 'e', 'c', 'l', 's', 'i', 'h', ...}
07:17:12.42 .............................. len(unknown_words) = 23
07:17:12.42 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 't', ' ', 'u', ' ', 'v', ' ', 'w', ' ']
07:17:12.42 .............................. len(fil_result) = 46
07:17:12.42  355 |                 for element in result:
07:17:12.42 ...................... element = 'x'
07:17:12.42  356 |                     if " " in element:
07:17:12.42  360 |                         filter(element)
07:17:12.42 .............................. unknown_words = {'b', 'k', 'd', 'w', 'g', 'f', 'j', 'n', 'v', 'r', 'p', 'a', 'x', 't', 'e', 'c', 'l', 's', 'i', ...}
07:17:12.42 .............................. len(unknown_words) = 24
07:17:12.42 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'u', ' ', 'v', ' ', 'w', ' ', 'x', ' ']
07:17:12.42 .............................. len(fil_result) = 48
07:17:12.42  355 |                 for element in result:
07:17:12.42 ...................... element = 'y'
07:17:12.42  356 |                     if " " in element:
07:17:12.42  360 |                         filter(element)
07:17:12.42 .............................. unknown_words = {'b', 'k', 'd', 'w', 'g', 'f', 'j', 'n', 'y', 'v', 'r', 'p', 'a', 'x', 't', 'e', 'c', 'l', 's', ...}
07:17:12.42 .............................. len(unknown_words) = 25
07:17:12.42 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'v', ' ', 'w', ' ', 'x', ' ', 'y', ' ']
07:17:12.42 .............................. len(fil_result) = 50
07:17:12.42  355 |                 for element in result:
07:17:12.42 ...................... element = 'z'
07:17:12.42  356 |                     if " " in element:
07:17:12.42  360 |                         filter(element)
07:17:12.43 .............................. len(unknown_words) = 26
07:17:12.43 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'w', ' ', 'x', ' ', 'y', ' ', 'z', ' ']
07:17:12.43 .............................. len(fil_result) = 52
07:17:12.43  355 |                 for element in result:
07:17:12.43  362 |                 fil_result.append("\n\n")
07:17:12.43 ...................... fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., 'w', ' ', 'x', ' ', 'y', ' ', 'z', ' ', '\n\n']
07:17:12.43 ...................... len(fil_result) = 53
07:17:12.43  363 |                 per_picture.append(fil_result)
07:17:12.43 ...................... per_picture = [['a', ' ', 'b', ..., 'z', ' ', '\n\n']]
07:17:12.43 ...................... len(per_picture) = 1
07:17:12.43  364 |                 fil_result = []
07:17:12.43  349 |         for file_type in images:
07:17:12.43 .............. file_type = '.jpf'
07:17:12.43  350 |             if files.endswith(file_type):
07:17:12.43  349 |         for file_type in images:
07:17:12.43 .............. file_type = '.jpeg'
07:17:12.43  350 |             if files.endswith(file_type):
07:17:12.43  349 |         for file_type in images:
07:17:12.43 .............. file_type = '.ppm'
07:17:12.43  350 |             if files.endswith(file_type):
07:17:12.43  349 |         for file_type in images:
07:17:12.43  348 |     for files in sourcefiles:
07:17:12.44 .......... files = '2021-09-15 08_10_38-(2) Facebook - Vivaldi.jpg'
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.tiff'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.gif'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.png'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.eps'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.bmp'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.44  349 |         for file_type in images:
07:17:12.44 .............. file_type = '.jpg'
07:17:12.44  350 |             if files.endswith(file_type):
07:17:12.45  351 |                 path = os.path.join(dir, files)
07:17:12.45 ...................... path = 'D:\\OCR\\test\\2021-09-15 08_10_38-(2) Facebook - Vivaldi.jpg'
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'a'
07:17:12.45  356 |                     if " " in element:
07:17:12.45  360 |                         filter(element)
07:17:12.45 .............................. fil_result = ['a', ' ']
07:17:12.45 .............................. len(fil_result) = 2
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'b'
07:17:12.45  356 |                     if " " in element:
07:17:12.45  360 |                         filter(element)
07:17:12.45 .............................. fil_result = ['a', ' ', 'b', ' ']
07:17:12.45 .............................. len(fil_result) = 4
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'c'
07:17:12.45  356 |                     if " " in element:
07:17:12.45  360 |                         filter(element)
07:17:12.45 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ']
07:17:12.45 .............................. len(fil_result) = 6
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'd'
07:17:12.45  356 |                     if " " in element:
07:17:12.45  360 |                         filter(element)
07:17:12.45 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ']
07:17:12.45 .............................. len(fil_result) = 8
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'e'
07:17:12.45  356 |                     if " " in element:
07:17:12.45  360 |                         filter(element)
07:17:12.45 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ']
07:17:12.45 .............................. len(fil_result) = 10
07:17:12.45  355 |                 for element in result:
07:17:12.45 ...................... element = 'f'
07:17:12.45  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ']
07:17:12.46 .............................. len(fil_result) = 12
07:17:12.46  355 |                 for element in result:
07:17:12.46 ...................... element = 'g'
07:17:12.46  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ']
07:17:12.46 .............................. len(fil_result) = 14
07:17:12.46  355 |                 for element in result:
07:17:12.46 ...................... element = 'h'
07:17:12.46  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ', 'h', ' ']
07:17:12.46 .............................. len(fil_result) = 16
07:17:12.46  355 |                 for element in result:
07:17:12.46 ...................... element = 'i'
07:17:12.46  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', 'f', ' ', 'g', ' ', 'h', ' ', 'i', ' ']
07:17:12.46 .............................. len(fil_result) = 18
07:17:12.46  355 |                 for element in result:
07:17:12.46 ...................... element = 'j'
07:17:12.46  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'g', ' ', 'h', ' ', 'i', ' ', 'j', ' ']
07:17:12.46 .............................. len(fil_result) = 20
07:17:12.46  355 |                 for element in result:
07:17:12.46 ...................... element = 'k'
07:17:12.46  356 |                     if " " in element:
07:17:12.46  360 |                         filter(element)
07:17:12.46 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'h', ' ', 'i', ' ', 'j', ' ', 'k', ' ']
07:17:12.46 .............................. len(fil_result) = 22
07:17:12.46  355 |                 for element in result:
07:17:12.48 ...................... element = 'l'
07:17:12.48  356 |                     if " " in element:
07:17:12.48  360 |                         filter(element)
07:17:12.48 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'l', ' ']
07:17:12.48 .............................. len(fil_result) = 24
07:17:12.48  355 |                 for element in result:
07:17:12.48 ...................... element = 'm'
07:17:12.48  356 |                     if " " in element:
07:17:12.48  360 |                         filter(element)
07:17:12.48 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'j', ' ', 'k', ' ', 'l', ' ', 'm', ' ']
07:17:12.48 .............................. len(fil_result) = 26
07:17:12.48  355 |                 for element in result:
07:17:12.48 ...................... element = 'n'
07:17:12.48  356 |                     if " " in element:
07:17:12.48  360 |                         filter(element)
07:17:12.48 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'k', ' ', 'l', ' ', 'm', ' ', 'n', ' ']
07:17:12.48 .............................. len(fil_result) = 28
07:17:12.48  355 |                 for element in result:
07:17:12.48 ...................... element = 'o'
07:17:12.48  356 |                     if " " in element:
07:17:12.48  360 |                         filter(element)
07:17:12.49 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'l', ' ', 'm', ' ', 'n', ' ', 'o', ' ']
07:17:12.49 .............................. len(fil_result) = 30
07:17:12.49  355 |                 for element in result:
07:17:12.49 ...................... element = 'p'
07:17:12.49  356 |                     if " " in element:
07:17:12.50  360 |                         filter(element)
07:17:12.50 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'm', ' ', 'n', ' ', 'o', ' ', 'p', ' ']
07:17:12.50 .............................. len(fil_result) = 32
07:17:12.50  355 |                 for element in result:
07:17:12.50 ...................... element = 'q'
07:17:12.50  356 |                     if " " in element:
07:17:12.50  360 |                         filter(element)
07:17:12.50 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'n', ' ', 'o', ' ', 'p', ' ', 'q', ' ']
07:17:12.50 .............................. len(fil_result) = 34
07:17:12.50  355 |                 for element in result:
07:17:12.50 ...................... element = 'r'
07:17:12.50  356 |                     if " " in element:
07:17:12.50  360 |                         filter(element)
07:17:12.50 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'o', ' ', 'p', ' ', 'q', ' ', 'r', ' ']
07:17:12.50 .............................. len(fil_result) = 36
07:17:12.50  355 |                 for element in result:
07:17:12.50 ...................... element = 's'
07:17:12.50  356 |                     if " " in element:
07:17:12.50  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'p', ' ', 'q', ' ', 'r', ' ', 's', ' ']
07:17:12.51 .............................. len(fil_result) = 38
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 't'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'q', ' ', 'r', ' ', 's', ' ', 't', ' ']
07:17:12.51 .............................. len(fil_result) = 40
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'u'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'r', ' ', 's', ' ', 't', ' ', 'u', ' ']
07:17:12.51 .............................. len(fil_result) = 42
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'v'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 's', ' ', 't', ' ', 'u', ' ', 'v', ' ']
07:17:12.51 .............................. len(fil_result) = 44
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'w'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 't', ' ', 'u', ' ', 'v', ' ', 'w', ' ']
07:17:12.51 .............................. len(fil_result) = 46
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'x'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'u', ' ', 'v', ' ', 'w', ' ', 'x', ' ']
07:17:12.51 .............................. len(fil_result) = 48
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'y'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'v', ' ', 'w', ' ', 'x', ' ', 'y', ' ']
07:17:12.51 .............................. len(fil_result) = 50
07:17:12.51  355 |                 for element in result:
07:17:12.51 ...................... element = 'z'
07:17:12.51  356 |                     if " " in element:
07:17:12.51  360 |                         filter(element)
07:17:12.51 .............................. fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., ' ', 'w', ' ', 'x', ' ', 'y', ' ', 'z', ' ']
07:17:12.51 .............................. len(fil_result) = 52
07:17:12.51  355 |                 for element in result:
07:17:12.51  362 |                 fil_result.append("\n\n")
07:17:12.51 ...................... fil_result = ['a', ' ', 'b', ' ', 'c', ' ', 'd', ' ', 'e', ' ', ..., 'w', ' ', 'x', ' ', 'y', ' ', 'z', ' ', '\n\n']
07:17:12.51 ...................... len(fil_result) = 53
07:17:12.51  363 |                 per_picture.append(fil_result)
07:17:12.53 ...................... per_picture = [['a', ' ', 'b', ..., 'z', ' ', '\n\n'], ['a', ' ', 'b', ..., 'z', ' ', '\n\n']]
07:17:12.53 ...................... len(per_picture) = 2
07:17:12.53  364 |                 fil_result = []
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.jpf'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.jpeg'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.ppm'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53  348 |     for files in sourcefiles:
07:17:12.53 .......... files = 'textfile.txt'
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.tiff'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.gif'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.png'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.eps'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.53 .............. file_type = '.bmp'
07:17:12.53  350 |             if files.endswith(file_type):
07:17:12.53  349 |         for file_type in images:
07:17:12.54 .............. file_type = '.jpg'
07:17:12.54  350 |             if files.endswith(file_type):
07:17:12.54  349 |         for file_type in images:
07:17:12.54 .............. file_type = '.jpf'
07:17:12.54  350 |             if files.endswith(file_type):
07:17:12.54  349 |         for file_type in images:
07:17:12.54 .............. file_type = '.jpeg'
07:17:12.54  350 |             if files.endswith(file_type):
07:17:12.54  349 |         for file_type in images:
07:17:12.54 .............. file_type = '.ppm'
07:17:12.54  350 |             if files.endswith(file_type):
07:17:12.54  349 |         for file_type in images:
07:17:12.54  348 |     for files in sourcefiles:
07:17:12.54 <<< Exit with block in <module>
[Finished in 1.7s]
alexmojaki commented 3 years ago

If you put your code inside a function, even if you still use with, that'll stop it from showing you all the global variables.

You can also use variable_whitelist which isn't documented, something like this:

import snoop

tracer = snoop()
tracer.variable_whitelist = {"x"}

with tracer:
    x = 1 + 2
    y = 3 + 4
    print(x + y)
Eliazar225 commented 3 years ago

You helped me, Thank You!