From 4025d7680552beb200688911e3ec87e11acf9365 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 1 Nov 2023 15:59:09 -0400 Subject: [PATCH 1/9] Update Python2 print commands left in comments and docs (#2128) --- Pythonwin/pywin/Demos/fontdemo.py | 7 ++- Pythonwin/pywin/Demos/ocx/webbrowser.py | 2 +- Pythonwin/pywin/Demos/splittst.py | 4 +- Pythonwin/pywin/Demos/threadedgui.py | 2 +- Pythonwin/pywin/debugger/debugger.py | 6 +-- .../pywin/framework/editor/ModuleBrowser.py | 2 +- .../framework/editor/color/coloreditor.py | 2 +- Pythonwin/pywin/framework/editor/editor.py | 2 +- Pythonwin/pywin/framework/editor/frame.py | 22 +++++----- Pythonwin/pywin/framework/editor/template.py | 6 +-- Pythonwin/pywin/framework/intpydde.py | 2 +- Pythonwin/pywin/framework/mdi_pychecker.py | 4 +- Pythonwin/pywin/framework/sgrepmdi.py | 4 +- Pythonwin/pywin/framework/toolmenu.py | 4 +- Pythonwin/pywin/mfc/object.py | 2 +- Pythonwin/pywin/scintilla/IDLEenvironment.py | 2 +- Pythonwin/pywin/scintilla/configui.py | 2 +- Pythonwin/pywin/scintilla/document.py | 2 +- Pythonwin/pywin/scintilla/formatter.py | 13 +++++- Pythonwin/pywin/scintilla/view.py | 13 +++++- Pythonwin/pywin/tools/hierlist.py | 8 ++-- Pythonwin/pywin/tools/regedit.py | 4 +- Pythonwin/win32util.cpp | 2 +- SWIG/swig_lib/timers.i | 2 +- adodbapi/quick_reference.md | 8 ++-- adodbapi/test/adodbapitest.py | 44 +++++++++++-------- adodbapi/test/test_adodbapi_dbapi20.py | 2 +- com/help/active_directory.html | 20 ++++----- com/help/adsi.html | 6 +-- com/help/mts.d | 6 +-- com/win32com/HTML/QuickStartClientCom.html | 4 +- com/win32com/HTML/QuickStartServerCom.html | 10 ++--- com/win32com/client/__init__.py | 6 +-- com/win32com/client/dynamic.py | 8 ++-- com/win32com/client/gencache.py | 16 +++---- com/win32com/client/genpy.py | 8 ++-- com/win32com/makegw/makegwparse.py | 11 ++++- com/win32com/server/util.py | 2 +- com/win32com/servers/dictionary.py | 2 +- com/win32com/test/testAccess.py | 4 +- com/win32com/test/testCollections.py | 8 ++-- com/win32com/test/testExchange.py | 4 +- com/win32com/test/testMarshal.py | 4 +- com/win32com/test/testPersist.py | 2 +- com/win32com/test/testROT.py | 2 +- com/win32com/test/util.py | 4 +- com/win32com/universal.py | 8 ++-- com/win32comext/axscript/client/debug.py | 2 +- com/win32comext/axscript/client/framework.py | 43 +++++++++++------- .../axscript/client/pyscript_rexec.py | 7 ++- .../axscript/demos/client/asp/caps.asp | 8 ++-- .../axscript/demos/client/ie/CHARTPY.HTM | 2 +- .../axscript/demos/client/ie/FOO.HTM | 2 +- .../axscript/demos/client/ie/calc.htm | 4 +- .../axscript/demos/client/ie/dbgtest.htm | 2 +- .../axscript/demos/client/ie/demo.htm | 6 +-- .../axscript/demos/client/ie/foo2.htm | 30 ++++++------- .../axscript/demos/client/ie/mousetrack.htm | 16 +++---- com/win32comext/axscript/test/leakTest.py | 10 ++--- com/win32comext/axscript/test/testHost4Dbg.py | 10 ++--- .../shell/demos/servers/empty_volume_cache.py | 4 +- .../shell/demos/servers/folder_view.py | 2 +- .../shell/demos/servers/shell_view.py | 8 ++-- isapi/samples/redirector.py | 2 +- isapi/samples/redirector_with_filter.py | 32 +++++++------- win32/Demos/OpenEncryptedFileRaw.py | 2 +- win32/Demos/cerapi.py | 4 +- win32/Demos/eventLogDemo.py | 2 +- win32/Demos/getfilever.py | 2 +- win32/Demos/rastest.py | 8 ++-- win32/Demos/security/get_policy_info.py | 4 +- win32/Demos/win32netdemo.py | 2 +- win32/Lib/pywin32_testutil.py | 3 +- win32/Lib/win32rcparser.py | 8 ++-- win32/Lib/win32traceutil.py | 2 +- win32/help/event.d | 23 +++++----- win32/help/file.d | 6 +-- win32/help/process_info.html | 10 ++--- win32/help/security.d | 8 ++-- win32/help/security_directories.html | 32 +++++++------- win32/help/win32net.html | 24 +++++----- win32/scripts/VersionStamp/bulkstamp.py | 2 +- win32/scripts/VersionStamp/vssutil.py | 7 ++- win32/scripts/regsetup.py | 2 +- win32/test/test_odbc.py | 2 +- win32/test/test_win32file.py | 2 +- win32/test/test_win32rcparser.py | 2 +- 87 files changed, 352 insertions(+), 303 deletions(-) diff --git a/Pythonwin/pywin/Demos/fontdemo.py b/Pythonwin/pywin/Demos/fontdemo.py index fc35f4ca38..4659f1c0ab 100644 --- a/Pythonwin/pywin/Demos/fontdemo.py +++ b/Pythonwin/pywin/Demos/fontdemo.py @@ -72,13 +72,12 @@ def FontDemo(): template = docview.DocTemplate(win32ui.IDR_PYTHONTYPE, None, None, FontView) doc = template.OpenDocumentFile(None) doc.SetTitle("Font Demo") - # print "template is ", template, "obj is", template._obj_ + # print("template is ", template, "obj is", template._obj_) template.close() + # print("closed") + # del template -# print "closed" -# del template - if __name__ == "__main__": import demoutils diff --git a/Pythonwin/pywin/Demos/ocx/webbrowser.py b/Pythonwin/pywin/Demos/ocx/webbrowser.py index 914b84a555..1dc318c198 100644 --- a/Pythonwin/pywin/Demos/ocx/webbrowser.py +++ b/Pythonwin/pywin/Demos/ocx/webbrowser.py @@ -24,7 +24,7 @@ def OnBeforeNavigate2( self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel ): self.GetParent().OnNavigate(URL) - # print "BeforeNavigate2", pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel + # print("BeforeNavigate2", pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel) class BrowserFrame(window.MDIChildWnd): diff --git a/Pythonwin/pywin/Demos/splittst.py b/Pythonwin/pywin/Demos/splittst.py index 0114bf09a3..2dbeb1e223 100644 --- a/Pythonwin/pywin/Demos/splittst.py +++ b/Pythonwin/pywin/Demos/splittst.py @@ -60,8 +60,8 @@ def __init__(self): ) def InitialUpdateFrame(self, frame, doc, makeVisible): - # print "frame is ", frame, frame._obj_ - # print "doc is ", doc, doc._obj_ + # print("frame is ", frame, frame._obj_) + # print("doc is ", doc, doc._obj_) self._obj_.InitialUpdateFrame(frame, doc, makeVisible) # call default handler. frame.InitialUpdateFrame(doc, makeVisible) diff --git a/Pythonwin/pywin/Demos/threadedgui.py b/Pythonwin/pywin/Demos/threadedgui.py index 556ed18d5c..5b0704ef3b 100644 --- a/Pythonwin/pywin/Demos/threadedgui.py +++ b/Pythonwin/pywin/Demos/threadedgui.py @@ -61,7 +61,7 @@ def OnTimer(self, id, timeVal): self.InvalidateRect() def OnPaint(self): - # print "Paint message from thread", win32api.GetCurrentThreadId() + # print("Paint message from thread", win32api.GetCurrentThreadId()) dc, paintStruct = self.BeginPaint() self.OnPrepareDC(dc, None) diff --git a/Pythonwin/pywin/debugger/debugger.py b/Pythonwin/pywin/debugger/debugger.py index 3b801fc851..17e64f7c5d 100644 --- a/Pythonwin/pywin/debugger/debugger.py +++ b/Pythonwin/pywin/debugger/debugger.py @@ -118,11 +118,11 @@ def __init__(self, debugger): HierListItem.__init__(self, debugger, None) self.last_stack = [] - ## def __del__(self): - ## print "HierStackRoot dieing" + # def __del__(self): + # print("HierStackRoot dieing") def GetSubList(self): debugger = self.myobject - # print self.debugger.stack, self.debugger.curframe + # print(self.debugger.stack, self.debugger.curframe) ret = [] if debugger.debuggerState == DBGSTATE_BREAK: stackUse = debugger.stack[:] diff --git a/Pythonwin/pywin/framework/editor/ModuleBrowser.py b/Pythonwin/pywin/framework/editor/ModuleBrowser.py index d1437e6a40..d7370e90cd 100644 --- a/Pythonwin/pywin/framework/editor/ModuleBrowser.py +++ b/Pythonwin/pywin/framework/editor/ModuleBrowser.py @@ -148,7 +148,7 @@ def DestroyBrowser(self): self.DestroyList() def OnActivateView(self, activate, av, dv): - # print "AV", self.bDirty, activate + # print("AV", self.bDirty, activate) if activate: self.CheckRefreshList() return self._obj_.OnActivateView(activate, av, dv) diff --git a/Pythonwin/pywin/framework/editor/color/coloreditor.py b/Pythonwin/pywin/framework/editor/color/coloreditor.py index 9de95a392f..518e2a1528 100644 --- a/Pythonwin/pywin/framework/editor/color/coloreditor.py +++ b/Pythonwin/pywin/framework/editor/color/coloreditor.py @@ -462,7 +462,7 @@ def FoldTopLevelEvent(self, event=None): - scintillacon.SC_FOLDLEVELBASE ) is_header = level & scintillacon.SC_FOLDLEVELHEADERFLAG - # print lineSeek, level_no, is_header + # print(lineSeek, level_no, is_header) if level_no == 0 and is_header: if (expanding and not self.SCIGetFoldExpanded(lineSeek)) or ( not expanding and self.SCIGetFoldExpanded(lineSeek) diff --git a/Pythonwin/pywin/framework/editor/editor.py b/Pythonwin/pywin/framework/editor/editor.py index e394a06bfb..6c332bd777 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -263,7 +263,7 @@ def Indent(self): else: curCol = curCol + 1 nextColumn = ((curCol / self.indentSize) + 1) * self.indentSize - # print "curCol is", curCol, "nextColumn is", nextColumn + # print("curCol is", curCol, "nextColumn is", nextColumn) ins = None if self.bSmartTabs: # Look for some context. diff --git a/Pythonwin/pywin/framework/editor/frame.py b/Pythonwin/pywin/framework/editor/frame.py index e927d16e5f..e0d97f37c4 100644 --- a/Pythonwin/pywin/framework/editor/frame.py +++ b/Pythonwin/pywin/framework/editor/frame.py @@ -25,15 +25,15 @@ def OnCreateClient(self, cp, context): splitter.CreateView(browserView, 0, 0, (0, 0)) sub_splitter.CreateView(view2, 0, 0, (0, 0)) - ## print "First view is", context.doc.GetFirstView() - ## print "Views are", view, view2, browserView - ## print "Parents are", view.GetParent(), view2.GetParent(), browserView.GetParent() - ## print "Splitter is", splitter - ## print "sub splitter is", sub_splitter - ## Old - ## splitter.CreateStatic (self, 1, 2) - ## splitter.CreateView(view, 0, 1, (0,0)) # size ignored. - ## splitter.CreateView (browserView, 0, 0, (0, 0)) + # print("First view is", context.doc.GetFirstView()) + # print("Views are", view, view2, browserView) + # print("Parents are", view.GetParent(), view2.GetParent(), browserView.GetParent()) + # print("Splitter is", splitter) + # print("sub splitter is", sub_splitter) + # Old + # splitter.CreateStatic (self, 1, 2) + # splitter.CreateView(view, 0, 1, (0,0)) # size ignored. + # splitter.CreateView (browserView, 0, 0, (0, 0)) # Restrict the size of the browser splitter (and we can avoid filling # it until it is shown) @@ -62,8 +62,8 @@ def GetBrowserView(self): def OnClose(self): doc = self.GetActiveDocument() if not doc.SaveModified(): - ## Cancel button selected from Save dialog, do not actually close - ## print 'close cancelled' + # Cancel button selected from Save dialog, do not actually close + # print("close cancelled") return 0 ## So the 'Save' dialog doesn't come up twice doc._obj_.SetModifiedFlag(False) diff --git a/Pythonwin/pywin/framework/editor/template.py b/Pythonwin/pywin/framework/editor/template.py index 362a74a62d..bbaed4e689 100644 --- a/Pythonwin/pywin/framework/editor/template.py +++ b/Pythonwin/pywin/framework/editor/template.py @@ -50,11 +50,11 @@ def OpenDocumentFile(self, filename, bMakeVisible=1): if filename is not None: try: path = os.path.split(filename)[0] - # print "The editor is translating", `filename`,"to", + # print("The editor is translating", "filename", "to") filename = win32api.FindFiles(filename)[0][8] filename = os.path.join(path, filename) - # print `filename` + # print("filename") except (win32api.error, IndexError) as details: + # print("Couldnt get the full filename!", details) pass - # print "Couldnt get the full filename!", details return self._obj_.OpenDocumentFile(filename, bMakeVisible) diff --git a/Pythonwin/pywin/framework/intpydde.py b/Pythonwin/pywin/framework/intpydde.py index 1f869b0f68..2401cdc566 100644 --- a/Pythonwin/pywin/framework/intpydde.py +++ b/Pythonwin/pywin/framework/intpydde.py @@ -21,7 +21,7 @@ def __init__(self, app): def Exec(self, data): try: - # print "Executing", cmd + # print("Executing", cmd) self.app.OnDDECommand(data) except: t, v, tb = sys.exc_info() diff --git a/Pythonwin/pywin/framework/mdi_pychecker.py b/Pythonwin/pywin/framework/mdi_pychecker.py index de43f349bc..bde43f775b 100644 --- a/Pythonwin/pywin/framework/mdi_pychecker.py +++ b/Pythonwin/pywin/framework/mdi_pychecker.py @@ -431,10 +431,10 @@ def GetParams(self): ) def OnSaveDocument(self, filename): - # print 'OnSaveDocument() filename=',filename + # print("OnSaveDocument() filename=",filename) savefile = open(filename, "wb") txt = self.GetParams() + "\n" - # print 'writing',txt + # print("writing",txt) savefile.write(txt) savefile.close() self.SetModifiedFlag(0) diff --git a/Pythonwin/pywin/framework/sgrepmdi.py b/Pythonwin/pywin/framework/sgrepmdi.py index 1c0d6339c4..a4068b5cd2 100644 --- a/Pythonwin/pywin/framework/sgrepmdi.py +++ b/Pythonwin/pywin/framework/sgrepmdi.py @@ -344,10 +344,10 @@ def GetParams(self): ) def OnSaveDocument(self, filename): - # print 'OnSaveDocument() filename=',filename + # print("OnSaveDocument() filename=", filename) savefile = open(filename, "wb") txt = self.GetParams() + "\n" - # print 'writing',txt + # print("writing", txt) savefile.write(txt) savefile.close() self.SetModifiedFlag(0) diff --git a/Pythonwin/pywin/framework/toolmenu.py b/Pythonwin/pywin/framework/toolmenu.py index afe06b2b41..1f16f9fca1 100644 --- a/Pythonwin/pywin/framework/toolmenu.py +++ b/Pythonwin/pywin/framework/toolmenu.py @@ -214,7 +214,7 @@ def OnOK(self): return self._obj_.OnOK() def OnCommandEditControls(self, id, cmd): - # print "OnEditControls", id, cmd + # print("OnEditControls", id, cmd) if cmd == win32con.EN_CHANGE and not self.bImChangingEditControls: itemNo = self.listControl.GetNextItem(-1, commctrl.LVNI_SELECTED) newText = self.editMenuCommand.GetWindowText() @@ -228,7 +228,7 @@ def OnNotifyListControlEndLabelEdit(self, id, cmd): self.listControl.SetItemText(itemNo, 0, newText) def OnNotifyListControl(self, id, cmd): - # print id, cmd + # print(id, cmd) try: itemNo = self.listControl.GetNextItem(-1, commctrl.LVNI_SELECTED) except win32ui.error: # No selection! diff --git a/Pythonwin/pywin/mfc/object.py b/Pythonwin/pywin/mfc/object.py index 063f835f76..62062a5351 100644 --- a/Pythonwin/pywin/mfc/object.py +++ b/Pythonwin/pywin/mfc/object.py @@ -33,7 +33,7 @@ def __getattr__( raise AttributeError(attr) def OnAttachedObjectDeath(self): - # print "object", self.__class__.__name__, "dieing" + # print("object", self.__class__.__name__, "dieing") self._obj_ = None def close(self): diff --git a/Pythonwin/pywin/scintilla/IDLEenvironment.py b/Pythonwin/pywin/scintilla/IDLEenvironment.py index f60f19de36..126d6db9e5 100644 --- a/Pythonwin/pywin/scintilla/IDLEenvironment.py +++ b/Pythonwin/pywin/scintilla/IDLEenvironment.py @@ -550,7 +550,7 @@ def test(): TestCheck("2.0", e, 13) try: TestCheck("sel.first", e, 0) - print "*** sel.first worked with an empty selection" + print("*** sel.first worked with an empty selection") except TextError: pass e.SetSel((4,5)) diff --git a/Pythonwin/pywin/scintilla/configui.py b/Pythonwin/pywin/scintilla/configui.py index 8b6157b604..9a3aeb3afe 100644 --- a/Pythonwin/pywin/scintilla/configui.py +++ b/Pythonwin/pywin/scintilla/configui.py @@ -228,7 +228,7 @@ def UpdateUIForStyle(self, style): sel = 0 for c in paletteVGA: if format[4] == c[1]: - # print "Style", style.name, "is", c[0] + # print("Style", style.name, "is", c[0]) break sel = sel + 1 else: diff --git a/Pythonwin/pywin/scintilla/document.py b/Pythonwin/pywin/scintilla/document.py index f7f542d6c0..bf0a2f03be 100644 --- a/Pythonwin/pywin/scintilla/document.py +++ b/Pythonwin/pywin/scintilla/document.py @@ -37,7 +37,7 @@ def DeleteContents(self): def OnOpenDocument(self, filename): # init data members - # print "Opening", filename + # print("Opening", filename) self.SetPathName(filename) # Must set this early! try: # load the text as binary we can get smart diff --git a/Pythonwin/pywin/scintilla/formatter.py b/Pythonwin/pywin/scintilla/formatter.py index 0df8015366..0f91968fa1 100644 --- a/Pythonwin/pywin/scintilla/formatter.py +++ b/Pythonwin/pywin/scintilla/formatter.py @@ -142,7 +142,7 @@ def _ReformatStyle(self, style): return assert style.stylenum is not None, "Unregistered style." - # print "Reformat style", style.name, style.stylenum + # print("Reformat style", style.name, style.stylenum) scintilla = self.scintilla stylenum = style.stylenum # Now we have the style number, indirect for the actual style. @@ -252,7 +252,16 @@ def OnStyleNeeded(self, std, extra): endStyledChar = self.scintilla.SendScintilla(scintillacon.SCI_GETENDSTYLED) lineEndStyled = self.scintilla.LineFromChar(endStyledChar) endStyled = self.scintilla.LineIndex(lineEndStyled) - # print "enPosPaint %d endStyledChar %d lineEndStyled %d endStyled %d" % (endPosPaint, endStyledChar, lineEndStyled, endStyled) + # print( + # "endPosPaint", + # endPosPaint, + # "endStyledChar", + # endStyledChar, + # "lineEndStyled", + # lineEndStyled, + # "endStyled", + # endStyled, + # ) self.Colorize(endStyled, notify.position) def ColorSeg(self, start, end, styleName): diff --git a/Pythonwin/pywin/scintilla/view.py b/Pythonwin/pywin/scintilla/view.py index cf570ea1f2..d877bf3805 100644 --- a/Pythonwin/pywin/scintilla/view.py +++ b/Pythonwin/pywin/scintilla/view.py @@ -691,7 +691,16 @@ def _GetWordSplit(self, pos=-1, bAllowCalls=0): return "".join(before), "".join(after) def OnPrepareDC(self, dc, pInfo): - # print "OnPrepareDC for page", pInfo.GetCurPage(), "of", pInfo.GetFromPage(), "to", pInfo.GetToPage(), ", starts=", self.starts + # print( + # "OnPrepareDC for page", + # pInfo.GetCurPage(), + # "of", + # pInfo.GetFromPage(), + # "to", + # pInfo.GetToPage(), + # ", starts=", + # self.starts, + # ) if dc.IsPrinting(): # Check if we are beyond the end. # (only do this when actually printing, else messes up print preview!) @@ -779,7 +788,7 @@ def FormatRange(self, dc, pageStart, lengthDoc, rc, draw): def OnPrint(self, dc, pInfo): metrics = dc.GetTextMetrics() - # print "dev", w, h, l, metrics['tmAscent'], metrics['tmDescent'] + # print("dev", w, h, l, metrics["tmAscent"], metrics["tmDescent"]) if self.starts is None: self.CalculatePageRanges(dc, pInfo) pageNum = pInfo.GetCurPage() - 1 diff --git a/Pythonwin/pywin/tools/hierlist.py b/Pythonwin/pywin/tools/hierlist.py index cc76f1905a..495eea78f9 100644 --- a/Pythonwin/pywin/tools/hierlist.py +++ b/Pythonwin/pywin/tools/hierlist.py @@ -220,9 +220,9 @@ def Refresh(self, hparent=None): inewlook = inewlook + 1 if matched: # Insert the new items. - # print "Inserting after", old_items[iold], old_handles[iold] + # print("Inserting after", old_items[iold], old_handles[iold]) for i in range(inew, inewlook): - # print "Inserting index %d (%s)" % (i, new_items[i]) + # print(f"Inserting index {i} ({new_items[i]})") hAfter = self.AddItem(hparent, new_items[i], hAfter) inew = inewlook + 1 @@ -232,7 +232,7 @@ def Refresh(self, hparent=None): self.Refresh(hold) else: # Remove the deleted items. - # print "Deleting %d (%s)" % (iold, old_items[iold]) + # print(f"Deleting {iold} ({old_items[iold]})") hdelete = old_handles[iold] # First recurse and remove the children from the map. for hchild in self._GetChildHandles(hdelete): @@ -243,7 +243,7 @@ def Refresh(self, hparent=None): hAfter = old_handles[iold] # Fill any remaining new items: for newItem in new_items[inew:]: - # print "Inserting new item", newItem + # print("Inserting new item", newItem) self.AddItem(hparent, newItem) def AcceptRoot(self, root): diff --git a/Pythonwin/pywin/tools/regedit.py b/Pythonwin/pywin/tools/regedit.py index c62a029910..1f83213ec0 100644 --- a/Pythonwin/pywin/tools/regedit.py +++ b/Pythonwin/pywin/tools/regedit.py @@ -159,9 +159,9 @@ def SelectedItem(self): def SearchSelectedItem(self): handle = self.hierList.GetChildItem(0) while 1: - # print "State is", self.hierList.GetItemState(handle, -1) + # print("State is", self.hierList.GetItemState(handle, -1)) if self.hierList.GetItemState(handle, commctrl.TVIS_SELECTED): - # print "Item is ", self.hierList.ItemFromHandle(handle) + # print("Item is ", self.hierList.ItemFromHandle(handle)) return self.hierList.ItemFromHandle(handle) handle = self.hierList.GetNextSiblingItem(handle) diff --git a/Pythonwin/win32util.cpp b/Pythonwin/win32util.cpp index 294301f7d1..529aae5281 100644 --- a/Pythonwin/win32util.cpp +++ b/Pythonwin/win32util.cpp @@ -933,7 +933,7 @@ BOOL ParseCharFormatTuple(PyObject *args, CHARFORMAT *pFmt) // @tupleitem 6|int|bPitchAndFamily|The charset. See the LOGFONT structure for details. // @tupleitem 7|string|faceName|The font name. - // @comm Executing d=win32ui.CreateFontDialog(); d.DoModal(); print d.GetCharFormat() + // @comm Executing d=win32ui.CreateFontDialog(); d.DoModal(); print(d.GetCharFormat()) // will print a valid CHARFORMAT tuple. } diff --git a/SWIG/swig_lib/timers.i b/SWIG/swig_lib/timers.i index 35924ae56a..1d90e699d3 100644 --- a/SWIG/swig_lib/timers.i +++ b/SWIG/swig_lib/timers.i @@ -134,7 +134,7 @@ performance. To use a timer, simply use code like this : timer_start(0) ... a bunch of Python code ... timer_stop(0) - print timer_elapsed(0)," seconds of CPU time" + print(timer_elapsed(0), " seconds of CPU time") %} #endif diff --git a/adodbapi/quick_reference.md b/adodbapi/quick_reference.md index e4bc9f9cfe..a61cf0a6a2 100644 --- a/adodbapi/quick_reference.md +++ b/adodbapi/quick_reference.md @@ -643,22 +643,22 @@ This is the PEP standard method: row = crsr.fetchone() while row: value = row[1] * row[2] - print('Your {:10s} is worth {:10.2f}'.format(row[0], value)) + print("Your {:10s} is worth {:10.2f}".format(row[0], value)) row = crsr.fetchone() # returns None when no data remains As an extension, a Row object can also be indexed by column name: crsr.execute("SELECT prodname, price, qtyonhand FROM cheese") for row in crsr: # note extension: using crsr as an iterator - value = row['price'] * row['qtyonhand'] - print('Your {:10s} is worth {:10.2f}'.format(row['prodname'], value)) + value = row["price"] * row["qtyonhand"] + print("Your {:10s} is worth {:10.2f}".format(row["prodname"], value)) But, _really_ lazy programmers, like me, use the column names as attributes: crsr.execute("SELECT prodname, price, qtyonhand FROM cheese") for row in crsr: value = row.price * row.qtyonhand - print('Your {:10s} is worth {:10.2f}'.format(row.prodname, value)) + print("Your {:10s} is worth {:10.2f}".format(row.prodname, value)) Now, isn't that easier to read and understand? diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index d7a4f2c9bc..e27bcaede1 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -1387,13 +1387,13 @@ def testOkConnect(self): assert c is not None # def testStoredProcedure(self): - # crsr=self.conn.cursor() + # crsr = self.conn.cursor() # try: # crsr.execute("DROP PROCEDURE DeleteMeOnlyForTesting") # self.conn.commit() - # except: #Make sure it is empty + # except: # Make sure it is empty # pass - # spdef= """ + # spdef = """ # DELIMITER $$ # CREATE PROCEDURE DeleteMeOnlyForTesting (onein CHAR(10), twoin CHAR(10), OUT theout CHAR(20)) # DETERMINISTIC @@ -1405,16 +1405,20 @@ def testOkConnect(self): # # crsr.execute(spdef) # - # retvalues=crsr.callproc('DeleteMeOnlyForTesting',('Dodsworth','Anne',' ')) - # print 'return value (mysql)=',repr(crsr.returnValue) ### - # assert retvalues[0]=='Dodsworth', '%s is not "Dodsworth"'%repr(retvalues[0]) - # assert retvalues[1]=='Anne','%s is not "Anne"'%repr(retvalues[1]) - # assert retvalues[2]=='DodsworthAnne','%s is not "DodsworthAnne"'%repr(retvalues[2]) + # retvalues = crsr.callproc( + # "DeleteMeOnlyForTesting", ("Dodsworth", "Anne", " ") + # ) + # print("return value (mysql)=", repr(crsr.returnValue)) + # assert retvalues[0] == "Dodsworth", '%s is not "Dodsworth"' % repr(retvalues[0]) + # assert retvalues[1] == "Anne", '%s is not "Anne"' % repr(retvalues[1]) + # assert retvalues[2] == "DodsworthAnne", '%s is not "DodsworthAnne"' % repr( + # retvalues[2] + # ) # # try: # crsr.execute("DROP PROCEDURE, DeleteMeOnlyForTesting") # self.conn.commit() - # except: #Make sure it is empty + # except: # Make sure it is empty # pass @@ -1453,8 +1457,8 @@ def testOkConnect(self): assert c is not None # def testStoredProcedure(self): - # crsr=self.conn.cursor() - # spdef= """ + # crsr = self.conn.cursor() + # spdef = """ # CREATE OR REPLACE FUNCTION DeleteMeOnlyForTesting (text, text) # RETURNS text AS $funk$ # BEGIN @@ -1463,18 +1467,22 @@ def testOkConnect(self): # $funk$ # LANGUAGE SQL; # """ - # + # crsr.execute(spdef) - # retvalues = crsr.callproc('DeleteMeOnlyForTesting',('Dodsworth','Anne',' ')) - # ### print 'return value (pg)=',repr(crsr.returnValue) ### - # assert retvalues[0]=='Dodsworth', '%s is not "Dodsworth"'%repr(retvalues[0]) - # assert retvalues[1]=='Anne','%s is not "Anne"'%repr(retvalues[1]) - # assert retvalues[2]=='Dodsworth Anne','%s is not "Dodsworth Anne"'%repr(retvalues[2]) + # retvalues = crsr.callproc( + # "DeleteMeOnlyForTesting", ("Dodsworth", "Anne", " ") + # ) + # # print("return value (pg)=", repr(crsr.returnValue)) + # assert retvalues[0] == "Dodsworth", '%s is not "Dodsworth"' % repr(retvalues[0]) + # assert retvalues[1] == "Anne", '%s is not "Anne"' % repr(retvalues[1]) + # assert retvalues[2] == "Dodsworth Anne", '%s is not "Dodsworth Anne"' % repr( + # retvalues[2] + # ) # self.conn.rollback() # try: # crsr.execute("DROP PROCEDURE, DeleteMeOnlyForTesting") # self.conn.commit() - # except: #Make sure it is empty + # except: # Make sure it is empty # pass diff --git a/adodbapi/test/test_adodbapi_dbapi20.py b/adodbapi/test/test_adodbapi_dbapi20.py index 6115138336..b90844bf6a 100644 --- a/adodbapi/test/test_adodbapi_dbapi20.py +++ b/adodbapi/test/test_adodbapi_dbapi20.py @@ -108,7 +108,7 @@ def setUp(self): if self.getTestMethodName() == "test_callproc": con = self._connect() engine = con.dbms_name - ## print('Using database Engine=%s' % engine) ## + # print(f"Using database Engine={engine}") if engine != "MS Jet": sql = """ create procedure templower diff --git a/com/help/active_directory.html b/com/help/active_directory.html index d7764002ba..4b93d8b0a7 100644 --- a/com/help/active_directory.html +++ b/com/help/active_directory.html @@ -114,7 +114,7 @@

Discovery

for i in servers: ex_servers.append(i.cn) - print '\texchange servers'," ".join(ex_servers) + print("\texchange servers"," ".join(ex_servers)) ex_first_store='CN=First Storage Group,CN=InformationStore,CN=%s,CN=Servers,CN=%s,%s'%(ex_servers[-1],admin_grp,ex_admin_grps) @@ -122,7 +122,7 @@

Discovery

for i in win32com.client.GetObject('LDAP://'+ex_first_store): ex_stores.append('cn='+i.cn+','+ex_first_store) - print '\tExchange stores:',"',".join(ex_stores) + print("\tExchange stores:","',".join(ex_stores))

Making the object

@@ -137,11 +137,11 @@

Making the object

This then allows things like:
-print('The last name: ',opends('fred').sn) #sn =surname +print("The last name: ",opends("fred").sn) #sn =surname
or to get the groups fred is a member of
-print("groups=',opends('fred').memberOf) +print("groups=",opends("fred").memberOf) def opends(loc,server=''): @@ -189,23 +189,23 @@

What does the object have?

def ad_dict(ldapobj,attr_dict={},recurse=0,auth=1,filter=()): if ldapobj.find(',')==-1: ldapobj='cn='+ldapobj+','+Ad.ldap_main_loc if auth: #setup authenticated connections - if debug: print 'auth' + if debug: print("auth") adobj=opends(ldapobj) - #if debug: print 'authenticated to',ldapobj + # if debug: print("authenticated to",ldapobj) else: adobj=win32com.client.GetObject('LDAP://'+ldapobj) - if debug: print 'connected to',ldapobj + if debug: print("connected to",ldapobj) if not(filter): #check for children for i in adobj: - if debug: print '****at',i.cn,str(adobj.cn) + if debug: print("****at",i.cn,str(adobj.cn)) if recurse: pass #get children's attributes too #attr_dict[i.distinguishedName]={} #get_all(i.distinguishedName,attr_dict[i.distinguishedName],recurse,auth) - if debug: print 'getting schema' + if debug: print("getting schema") schema_obj=win32com.client.GetObject(adobj.schema) for i in schema_obj.MandatoryProperties: if i =='nTSecurityDescriptor':continue #takes a long time, skip it @@ -246,7 +246,7 @@

The time property

user=opends('fred') -print 'time in seconds',conv_time(user.pwdLastSet.lowpart,user.pwdLastSet.highpart) +print("time in seconds",conv_time(user.pwdLastSet.lowpart,user.pwdLastSet.highpart)) user.pwdLastSet returns a com object, not a python data type. diff --git a/com/help/adsi.html b/com/help/adsi.html index 6fd2ab119e..d97b0d6838 100644 --- a/com/help/adsi.html +++ b/com/help/adsi.html @@ -152,7 +152,7 @@

Getting/Modify user info

myDSObject.Getinfo() # To access a user's data try: attribute = myDSObject.Get('Extension-Attribute-1') -print attribute +print(attribute) # To modify a user try: myDSObject.Put('Extension-Attribute-1','barney was here') myDSObject.Setinfo() @@ -188,7 +188,7 @@

Deleting a user from exchange

dsobj.Delete("OrganizationalPerson", "cn="+login) dsobj.Setinfo() except: - print 'Error deleting '+login, sys.exc_type , sys.exc_value + print("Error deleting "+login, sys.exc_type , sys.exc_value)


@@ -245,7 +245,7 @@

Recursively listing all unique members of a distribution elif dsobj.Class=='Public-Folder': pass else: - print 'skipped',dsobj.Class,dsobj.uid + print("skipped",dsobj.Class,dsobj.uid) return user_dict diff --git a/com/help/mts.d b/com/help/mts.d index 2e20835073..321091b6e1 100644 --- a/com/help/mts.d +++ b/com/help/mts.d @@ -83,9 +83,9 @@ from win32com.server.exception import COMException import win32com.server.util import win32com.client.dynamic -#to generate guids use: -#import pythoncom -#print pythoncom.CreateGuid() +# to generate guids use: +# import pythoncom +# print(pythoncom.CreateGuid()) class Mts: # COM attributes. diff --git a/com/win32com/HTML/QuickStartClientCom.html b/com/win32com/HTML/QuickStartClientCom.html index f3a0274256..c6e7c259fb 100644 --- a/com/win32com/HTML/QuickStartClientCom.html +++ b/com/win32com/HTML/QuickStartClientCom.html @@ -26,11 +26,11 @@

To use a COM object from Python

o = win32com.client.Dispatch("Object.Name")
o.Method()
o.property = "New Value"
-print o.property

+print(o.property)

Example

o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
-o.Workbooks.Add() # for office 97 – 95 a bit different!
+o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"

And we will see the word "Hello" appear in the top cell.

How do I know which methods and properties are available?

diff --git a/com/win32com/HTML/QuickStartServerCom.html b/com/win32com/HTML/QuickStartServerCom.html index b956daaf01..584e34e80d 100644 --- a/com/win32com/HTML/QuickStartServerCom.html +++ b/com/win32com/HTML/QuickStartServerCom.html @@ -39,7 +39,7 @@

Implement a stand-alone Python class with your functionality

This is obviously a very simple server. In particular, custom error handling would be needed for a production class server. In addition, there are some contrived properties just for demonstration purposes.

Make Unicode concessions

-

At this stage, Python and Unicode don’t really work well together. All strings which come from COM will actually be Unicode objects rather than string objects.

+

At this stage, Python and Unicode don’t really work well together. All strings which come from COM will actually be Unicode objects rather than string objects.

To make this code work in a COM environment, the last line of the "Hello" method must become:

@@ -85,7 +85,7 @@

Annotate the class with win32com specific attributes

_public_attrs_ = ['softspace', 'noCalls']

_readonly_attrs_ = ['noCalls']

def __init__(self):

-

[Same from here…]

+

[Same from here…]

Registering and assigning a CLSID for the object

@@ -93,7 +93,7 @@

Annotate the class with win32com specific attributes

Generating the CLSID

Microsoft Visual C++ comes with various tools for generating CLSID's, which are quite suitable. Alternatively, the pythoncom module exports the function CreateGuid() to generate these identifiers.

>>> import pythoncom
->>> print pythoncom.CreateGuid()
+>>> print(pythoncom.CreateGuid())
{7CC9F362-486D-11D1-BB48-0000E838A65F}

Obviously the GUID that you get will be different than that displayed here.

Preparing for registration of the Class

@@ -179,13 +179,13 @@

Exception Handling

Default Policy attributes

The default policy object has a few special attributes that define who the object is exposed to COM. The example above shows the _public_methods attribute, but this section describes all such attributes in detail.

_public_methods_
-

Required list of strings, containing the names of all methods to be exposed to COM. It is possible this will be enhanced in the future (eg, possibly '*' will be recognised to say all methods, or some other ideas…)

+

Required list of strings, containing the names of all methods to be exposed to COM. It is possible this will be enhanced in the future (eg, possibly '*' will be recognised to say all methods, or some other ideas…)

_public_attrs_

Optional list of strings containing all attribute names to be exposed, both for reading and writing. The attribute names must be valid instance variables.

_readonly_attrs_

Optional list of strings defining the name of attributes exposed read-only.

_com_interfaces_
-

Optional list of IIDs exposed by this object. If this attribute is missing, IID_IDispatch is assumed (ie, if not supplied, the COM object will be created as a normal Automation object.

+

Optional list of IIDs exposed by this object. If this attribute is missing, IID_IDispatch is assumed (ie, if not supplied, the COM object will be created as a normal Automation object).

and actual instance attributes:

_dynamic_ : optional method

_value_ : optional attribute

diff --git a/com/win32com/client/__init__.py b/com/win32com/client/__init__.py index 6f8ad07088..36f2c1d778 100644 --- a/com/win32com/client/__init__.py +++ b/com/win32com/client/__init__.py @@ -303,7 +303,7 @@ class object that derives from three classes: >>> class IEEvents: ... def OnVisible(self, visible): - ... print "Visible changed:", visible + ... print("Visible changed:", visible) ... >>> ie = DispatchWithEvents("InternetExplorer.Application", IEEvents) >>> ie.Visible = 1 @@ -358,7 +358,7 @@ def WithEvents(disp, user_event_class): >>> class IEEvents: ... def OnVisible(self, visible): - ... print "Visible changed:", visible + ... print("Visible changed:", visible) ... >>> ie = Dispatch("InternetExplorer.Application") >>> ie_events = WithEvents(ie, IEEvents) @@ -437,7 +437,7 @@ def getevents(clsid): >>> >>> class InternetExplorerEvents(win32com.client.getevents("InternetExplorer.Application.1")): ... def OnVisible(self, Visible): - ... print "Visibility changed: ", Visible + ... print("Visibility changed: ", Visible) ... >>> >>> ie=win32com.client.Dispatch("InternetExplorer.Application.1") diff --git a/com/win32com/client/dynamic.py b/com/win32com/client/dynamic.py index dc938e8cbe..4c38ba3b1b 100644 --- a/com/win32com/client/dynamic.py +++ b/com/win32com/client/dynamic.py @@ -234,7 +234,7 @@ def __repr__(self): return "" % (self._username_) def __str__(self): - # __str__ is used when the user does "print object", so we gracefully + # __str__ is used when the user does "print(object)", so we gracefully # fall back to the __repr__ if the object has no default method. try: return str(self.__call__()) @@ -330,7 +330,7 @@ def __getitem__(self, index): # syver modified def __setitem__(self, index, *args): # XXX - todo - We should support calling Item() here too! - # print "__setitem__ with", index, args + # print("__setitem__ with", index, args) if self._olerepr_.defaultDispatchName: invkind, dispid = self._find_dispatch_type_( self._olerepr_.defaultDispatchName @@ -414,8 +414,8 @@ def _make_method_(self, name): ) methodCode = "\n".join(methodCodeList) try: - # print "Method code for %s is:\n" % self._username_, methodCode - # self._print_details_() + # print(f"Method code for {self._username_} is:\n", methodCode) + # self._print_details_() codeObject = compile(methodCode, "" % self._username_, "exec") # Exec the code object tempNameSpace = {} diff --git a/com/win32com/client/gencache.py b/com/win32com/client/gencache.py index debe796213..c7bbbca3cb 100644 --- a/com/win32com/client/gencache.py +++ b/com/win32com/client/gencache.py @@ -458,7 +458,7 @@ def EnsureModule( # If we get an ImportError # We may still find a valid cache file under a different MinorVersion # # (which windows will search out for us) - # print "Loading reg typelib", typelibCLSID, major, minor, lcid + # print("Loading reg typelib", typelibCLSID, major, minor, lcid) module = None try: tlbAttr = pythoncom.LoadRegTypeLib( @@ -467,7 +467,7 @@ def EnsureModule( # if the above line doesn't throw a pythoncom.com_error, check if # it is actually a different lib than we requested, and if so, suck it in if tlbAttr[1] != lcid or tlbAttr[4] != minor: - # print "Trying 2nd minor #", tlbAttr[1], tlbAttr[3], tlbAttr[4] + # print("Trying 2nd minor #", tlbAttr[1], tlbAttr[3], tlbAttr[4]) try: module = GetModuleForTypelib( typelibCLSID, tlbAttr[1], tlbAttr[3], tlbAttr[4] @@ -525,7 +525,7 @@ def EnsureModule( module.MinorVersion != tlbAttributes[4] or genpy.makepy_version != module.makepy_version ): - # print "Version skew: %d, %d" % (module.MinorVersion, tlbAttributes[4]) + # print(f"Version skew: {module.MinorVersion}, {tlbAttributes[4]}") # try to erase the bad file from the cache try: os.unlink(filePath) @@ -550,21 +550,21 @@ def EnsureModule( ) filePath = filePathPrefix + ".py" filePathPyc = filePathPrefix + ".pyc" - # print "Trying py stat: ", filePath + # print("Trying py stat: ", filePath) fModTimeSet = 0 try: pyModTime = os.stat(filePath)[8] fModTimeSet = 1 except OSError as e: # If .py file fails, try .pyc file - # print "Trying pyc stat", filePathPyc + # print("Trying pyc stat", filePathPyc) try: pyModTime = os.stat(filePathPyc)[8] fModTimeSet = 1 except OSError as e: pass - # print "Trying stat typelib", pyModTime - # print str(typLibPath) + # print("Trying stat typelib", pyModTime) + # print(typLibPath) typLibModTime = os.stat(typLibPath)[8] if fModTimeSet and (typLibModTime > pyModTime): bReloadNeeded = 1 @@ -598,7 +598,7 @@ def EnsureModule( # remember and return versionRedirectMap[key] = ret return ret - # print "Rebuilding: ", major, minor + # print("Rebuilding: ", major, minor) module = MakeModuleForTypelib( typelibCLSID, lcid, diff --git a/com/win32com/client/genpy.py b/com/win32com/client/genpy.py index 06f11889cd..d23cd3079f 100644 --- a/com/win32com/client/genpy.py +++ b/com/win32com/client/genpy.py @@ -207,10 +207,10 @@ def __init__(self, typeinfo, attr, doc=None, bForUser=1): name = typeinfo.GetNames(vdesc[0])[0] self.mapVars[name] = build.MapEntry(vdesc) - ## def WriteEnumerationHeaders(self, aliasItems, stream): - ## enumName = self.doc[0] - ## print >> stream "%s=constants # Compatibility with previous versions." % (enumName) - ## WriteAliasesForItem(self, aliasItems) + # def WriteEnumerationHeaders(self, aliasItems, stream): + # enumName = self.doc[0] + # print(f"{enumName}=constants # Compatibility with previous versions.", file=stream) + # WriteAliasesForItem(self, aliasItems) def WriteEnumerationItems(self, stream): num = 0 diff --git a/com/win32com/makegw/makegwparse.py b/com/win32com/makegw/makegwparse.py index ba32c7fa36..0090c558b7 100644 --- a/com/win32com/makegw/makegwparse.py +++ b/com/win32com/makegw/makegwparse.py @@ -37,7 +37,7 @@ class ArgFormatter: """An instance for a specific type of argument. Knows how to convert itself""" def __init__(self, arg, builtinIndirection, declaredIndirection=0): - # print 'init:', arg.name, builtinIndirection, declaredIndirection, arg.indirectionLevel + # print("init:", arg.name, builtinIndirection, declaredIndirection, arg.indirectionLevel) self.arg = arg self.builtinIndirection = builtinIndirection self.declaredIndirection = declaredIndirection @@ -64,7 +64,14 @@ def _IndirectPrefix(self, indirectionFrom, indirectionTo): raise error_not_supported("Can't indirect this far - please fix me :-)") def GetIndirectedArgName(self, indirectFrom, indirectionTo): - # print 'get:',self.arg.name, indirectFrom,self._GetDeclaredIndirection() + self.builtinIndirection, indirectionTo, self.arg.indirectionLevel + # print( + # "get:", + # self.arg.name, + # indirectFrom, + # self._GetDeclaredIndirection() + self.builtinIndirection, + # indirectionTo, + # self.arg.indirectionLevel, + # ) if indirectFrom is None: ### ACK! this does not account for [in][out] variables. diff --git a/com/win32com/server/util.py b/com/win32com/server/util.py index c46dd375d9..853f03a2b1 100644 --- a/com/win32com/server/util.py +++ b/com/win32com/server/util.py @@ -144,7 +144,7 @@ def __init__(self, data=None, readOnly=0): self._public_methods_ = ["Item", "Count"] # This method is also used as the "default" method. - # Thus "print ob" will cause this to be called with zero + # Thus "print(ob)" will cause this to be called with zero # params. Handle this slightly more elegantly here. # Ideally the policy should handle this. def Item(self, *args): diff --git a/com/win32com/servers/dictionary.py b/com/win32com/servers/dictionary.py index c8ec986377..72b405937e 100644 --- a/com/win32com/servers/dictionary.py +++ b/com/win32com/servers/dictionary.py @@ -27,7 +27,7 @@ the dictionary's keys. This allows for the following type of VB code: for each name in ob - debug.print name, ob(name) + debug.print(name, ob(name)) next """ diff --git a/com/win32com/test/testAccess.py b/com/win32com/test/testAccess.py index 1d41eb6fc5..50332db021 100644 --- a/com/win32com/test/testAccess.py +++ b/com/win32com/test/testAccess.py @@ -122,8 +122,8 @@ def DoDumpAccessInfo(dbname): forms = a.Forms print("There are %d forms open." % (len(forms))) # Uncommenting these lines means Access remains open. - # for form in forms: - # print " %s" % form.Name + # for form in forms: + # print(f" {form.Name}") reports = a.Reports print("There are %d reports open" % (len(reports))) finally: diff --git a/com/win32com/test/testCollections.py b/com/win32com/test/testCollections.py index 999c65b09f..10bfce775b 100644 --- a/com/win32com/test/testCollections.py +++ b/com/win32com/test/testCollections.py @@ -102,10 +102,10 @@ def TestEnum(quiet=None): TestEnumAgainst(o, check) ### This does not work! - # if not quiet: print "Indexed replace item test" - # o[2] = 'Replaced Item' - # check[2] = 'Replaced Item' - # TestEnumAgainst(o, check) + # if not quiet: print("Indexed replace item test") + # o[2] = 'Replaced Item' + # check[2] = 'Replaced Item' + # TestEnumAgainst(o, check) try: o() diff --git a/com/win32com/test/testExchange.py b/com/win32com/test/testExchange.py index bad0e121e6..fa2ac5cb05 100644 --- a/com/win32com/test/testExchange.py +++ b/com/win32com/test/testExchange.py @@ -75,8 +75,8 @@ def DumpFolders(session): def TestAddress(session): - # entry = session.GetAddressEntry("Skip") - # print entry + # entry = session.GetAddressEntry("Skip") + # print(entry) pass diff --git a/com/win32com/test/testMarshal.py b/com/win32com/test/testMarshal.py index c57d445f87..6c9a6ce902 100644 --- a/com/win32com/test/testMarshal.py +++ b/com/win32com/test/testMarshal.py @@ -52,7 +52,7 @@ def _doTestInThread(self, interp): interp = win32com.client.Dispatch(interp) interp.Exec("import win32api") - # print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()")) + # print(f"The test thread id is {myThread}, Python.Interpreter's thread ID is {interp.Eval('win32api.GetCurrentThreadId()')}") pythoncom.CoUninitialize() def BeginThreadsSimpleMarshal(self, numThreads): @@ -108,7 +108,7 @@ def BeginThreadsFastMarshal(self, numThreads): return threads, events def _DoTestMarshal(self, fn, bCoWait=0): - # print "The main thread is %d" % (win32api.GetCurrentThreadId()) + # print(f"The main thread is {win32api.GetCurrentThreadId()}") threads, events = fn(2) numFinished = 0 while 1: diff --git a/com/win32com/test/testPersist.py b/com/win32com/test/testPersist.py index 76f7d84c96..5ca6053f7d 100644 --- a/com/win32com/test/testPersist.py +++ b/com/win32com/test/testPersist.py @@ -45,7 +45,7 @@ def WriteAt(self, offset, data): print("WriteAt " + str(offset)) print("len " + str(len(data))) print("data:") - # print data + # print(data) if len(self.data) >= offset: newdata = self.data[0:offset] + data print(len(newdata)) diff --git a/com/win32com/test/testROT.py b/com/win32com/test/testROT.py index 5a4ccbcc8c..91e30894d5 100644 --- a/com/win32com/test/testROT.py +++ b/com/win32com/test/testROT.py @@ -22,7 +22,7 @@ def testit(self): raise # if num < 2: - # print "Only", num, "objects in the ROT - this is unusual" + # print("Only", num, "objects in the ROT - this is unusual") if __name__ == "__main__": diff --git a/com/win32com/test/util.py b/com/win32com/test/util.py index 73dfd1f2a0..a809875989 100644 --- a/com/win32com/test/util.py +++ b/com/win32com/test/util.py @@ -61,7 +61,7 @@ def RegisterPythonServer(filename, progids=None, verbose=0): ) break else: - # print "Skipping registration of '%s' - already registered" % filename + # print(f"Skipping registration of '{filename}' - already registered") return # needs registration - see if its likely! try: @@ -89,7 +89,7 @@ def RegisterPythonServer(filename, progids=None, verbose=0): cmd = f'{win32api.GetModuleFileName(0)} "{filename}" --unattended > nul 2>&1' if verbose: print("Registering engine", filename) - # print cmd + # print(cmd) rc = os.system(cmd) if rc: print("Registration command was:") diff --git a/com/win32com/universal.py b/com/win32com/universal.py index 6a87f6857e..055312acdc 100644 --- a/com/win32com/universal.py +++ b/com/win32com/universal.py @@ -68,7 +68,7 @@ def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names=None): raise ValueError( f"Interface '{name}' does not exist in this cached typelib" ) - # print "Processing interface", name + # print("Processing interface", name) sub_mod = gencache.GetModuleForCLSID(iid) is_dispatch = getattr(sub_mod, name + "_vtables_dispatch_", None) method_defs = getattr(sub_mod, name + "_vtables_", None) @@ -100,10 +100,10 @@ def _CalcTypeSize(typeTuple): # is trying to. We need to better place to warn about this, but it # isn't here. # try: - # import warnings - # warnings.warn("warning: records are known to not work for vtable interfaces") + # import warnings + # warnings.warn("warning: records are known to not work for vtable interfaces") # except ImportError: - # print "warning: records are known to not work for vtable interfaces" + # print("warning: records are known to not work for vtable interfaces") cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1] # cb = typeInfo.GetTypeAttr().cbSizeInstance else: diff --git a/com/win32comext/axscript/client/debug.py b/com/win32comext/axscript/client/debug.py index b1d7dabec7..bdae7aac62 100644 --- a/com/win32comext/axscript/client/debug.py +++ b/com/win32comext/axscript/client/debug.py @@ -99,7 +99,7 @@ def Close(self): self.adb.CloseApp() self.adb = None - # print "Close complete" + # print("Close complete") def IsAnyHost(self): "Do we have _any_ debugging interfaces installed?" diff --git a/com/win32comext/axscript/client/framework.py b/com/win32comext/axscript/client/framework.py index f94c553111..93f9d53741 100644 --- a/com/win32comext/axscript/client/framework.py +++ b/com/win32comext/axscript/client/framework.py @@ -168,7 +168,7 @@ def Build(self, typeinfo, funcdesc): self.name = typeinfo.GetNames(self.dispid)[0] -# print "Event.Build() - Event Name is ", self.name +# print("Event.Build() - Event Name is ", self.name) class EventSink: @@ -207,7 +207,7 @@ def _invoke_(self, dispid, lcid, wFlags, args): event = self.events[dispid] except: raise Exception(scode=winerror.DISP_E_MEMBERNOTFOUND) - # print "Invoke for ", event, "on", self.myScriptItem, " - calling", self.myInvokeMethod + # print("Invoke for ", event, "on", self.myScriptItem, " - calling", self.myInvokeMethod) return self.myInvokeMethod(self.myScriptItem, event, lcid, wFlags, args) def GetSourceTypeInfo(self, typeinfo): @@ -352,16 +352,16 @@ def Register(self): if self.isRegistered: return # Get the type info to use to build this item. - # if not self.dispatch: - # id = self.parentItem.dispatch.GetIDsOfNames(self.name) - # print "DispID of me is", id - # result = self.parentItem.dispatch.Invoke(id, 0, pythoncom.DISPATCH_PROPERTYGET,1) - # if isinstance(result, pythoncom.TypeIIDs[pythoncom.IID_IDispatch]): - # self.dispatch = result - # else: - # print "*** No dispatch" - # return - # print "**** Made dispatch" + # if not self.dispatch: + # id = self.parentItem.dispatch.GetIDsOfNames(self.name) + # print("DispID of me is", id) + # result = self.parentItem.dispatch.Invoke(id, 0, pythoncom.DISPATCH_PROPERTYGET,1) + # if isinstance(result, pythoncom.TypeIIDs[pythoncom.IID_IDispatch]): + # self.dispatch = result + # else: + # print("*** No dispatch") + # return + # print("**** Made dispatch") self.isRegistered = 1 # Register the sub-items. for item in self.subItems.values(): @@ -516,7 +516,18 @@ def FindBuildSubItemEvents(self): subObj = self.GetCreateSubItem( self, name, result, axscript.SCRIPTITEM_ISVISIBLE ) - # print "subobj", name, "flags are", subObj.flags, "mydisp=", self.dispatch, "result disp=", result, "compare=", self.dispatch==result + # print( + # "subobj", + # name, + # "flags are", + # subObj.flags, + # "mydisp=", + # self.dispatch, + # "result disp=", + # result, + # "compare=", + # self.dispatch == result, + # ) subObj.BuildEvents() subObj.Register() except pythoncom.com_error: @@ -762,7 +773,7 @@ def GetScriptSite(self, iid): return self.scriptSite.QueryInterface(iid) def SetScriptState(self, state): - # print "SetScriptState with %s - currentstate = %s" % (state_map.get(state),state_map.get(self.scriptState)) + # print(f"SetScriptState with {state_map.get(state)} - currentstate = {state_map.get(self.scriptState)}" if state == self.scriptState: return # If closed, allow no other state transitions @@ -1049,7 +1060,7 @@ def Reset(self): self.ChangeScriptState(axscript.SCRIPTSTATE_INITIALIZED) def ChangeScriptState(self, state): - # print " ChangeScriptState with %s - currentstate = %s" % (state_map.get(state),state_map.get(self.scriptState)) + # print(f" ChangeScriptState with {state_map.get(state)} - currentstate = {state_map.get(self.scriptState)}") self.DisableInterrupts() try: self.scriptState = state @@ -1076,7 +1087,7 @@ def ApplyInScriptedSection(self, codeBlock, fn, args): self.BeginScriptedSection() try: try: - # print "ApplyInSS", codeBlock, fn, args + # print("ApplyInSS", codeBlock, fn, args) return self._ApplyInScriptedSection(fn, args) finally: if self.debugManager: diff --git a/com/win32comext/axscript/client/pyscript_rexec.py b/com/win32comext/axscript/client/pyscript_rexec.py index a07b5a1654..3224be89cf 100644 --- a/com/win32comext/axscript/client/pyscript_rexec.py +++ b/com/win32comext/axscript/client/pyscript_rexec.py @@ -31,7 +31,12 @@ class PyScriptRExec(pyscript.PyScript): _reg_threading_ = "Apartment" def _GetSupportedInterfaceSafetyOptions(self): - # print "**** calling", pyscript.PyScript._GetSupportedInterfaceSafetyOptions, "**->", pyscript.PyScript._GetSupportedInterfaceSafetyOptions(self) + # print( + # "**** calling", + # pyscript.PyScript._GetSupportedInterfaceSafetyOptions, + # "**->", + # pyscript.PyScript._GetSupportedInterfaceSafetyOptions(self), + # ) return ( INTERFACE_USES_DISPEX | INTERFACE_USES_SECURITY_MANAGER diff --git a/com/win32comext/axscript/demos/client/asp/caps.asp b/com/win32comext/axscript/demos/client/asp/caps.asp index 6b0342aa32..8ea7cf8de4 100644 --- a/com/win32comext/axscript/demos/client/asp/caps.asp +++ b/com/win32comext/axscript/demos/client/asp/caps.asp @@ -23,11 +23,11 @@ Response.Write("

Win32 username is "+win32api.GetUserName()) <% import sys -print sys.path +print(sys.path) from win32com.axscript.asputil import * -print "Hello" -print "There" -print "How are you" +print("Hello") +print("There") +print("How are you") %> <%bc = Server.CreateObject("MSWC.BrowserType")%> diff --git a/com/win32comext/axscript/demos/client/ie/CHARTPY.HTM b/com/win32comext/axscript/demos/client/ie/CHARTPY.HTM index 4bba12c19e..fe7d1b5fbd 100644 --- a/com/win32comext/axscript/demos/client/ie/CHARTPY.HTM +++ b/com/win32comext/axscript/demos/client/ie/CHARTPY.HTM @@ -75,7 +75,7 @@ def DoChartType(WhatType): # Turns horizontal gridlines on or off depending on value of chkHorizontal checkbox def DoHorizontalGrid(): - print ax.chkHorizontal.Checked + print(ax.chkHorizontal.Checked) if ax.chkHorizontal.Checked: ax.Chart1.HGridStyle = 1 else: diff --git a/com/win32comext/axscript/demos/client/ie/FOO.HTM b/com/win32comext/axscript/demos/client/ie/FOO.HTM index 840672ff9c..34a880fa8d 100644 --- a/com/win32comext/axscript/demos/client/ie/FOO.HTM +++ b/com/win32comext/axscript/demos/client/ie/FOO.HTM @@ -39,7 +39,7 @@ End Sub diff --git a/com/win32comext/axscript/demos/client/ie/calc.htm b/com/win32comext/axscript/demos/client/ie/calc.htm index 46ef9a41fe..8c190b1abd 100644 --- a/com/win32comext/axscript/demos/client/ie/calc.htm +++ b/com/win32comext/axscript/demos/client/ie/calc.htm @@ -10,7 +10,7 @@ numberButNames = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] def NumPressed(Num): - print "NumPressed", Num + print("NumPressed", Num) global FlagNewNum if FlagNewNum: ax.document.Keypad.ReadOut.Value = Num @@ -42,7 +42,7 @@ def Operation(Op, fn): global FlagNewNum, PendingOp, Accum ReadOut = ax.document.Keypad.ReadOut.Value - print "Operation", Op, ReadOut, PendingOp, Accum + print("Operation", Op, ReadOut, PendingOp, Accum) if FlagNewNum: # User is hitting op keys repeatedly, so don't do anything PendingOp = NullOp diff --git a/com/win32comext/axscript/demos/client/ie/dbgtest.htm b/com/win32comext/axscript/demos/client/ie/dbgtest.htm index 7ee9468d58..a36d83ceee 100644 --- a/com/win32comext/axscript/demos/client/ie/dbgtest.htm +++ b/com/win32comext/axscript/demos/client/ie/dbgtest.htm @@ -6,7 +6,7 @@ diff --git a/com/win32comext/axscript/demos/client/ie/foo2.htm b/com/win32comext/axscript/demos/client/ie/foo2.htm index d5e0c4a624..d967822b9e 100644 --- a/com/win32comext/axscript/demos/client/ie/foo2.htm +++ b/com/win32comext/axscript/demos/client/ie/foo2.htm @@ -8,9 +8,9 @@ @@ -36,10 +36,10 @@ @@ -54,7 +54,7 @@ - +
@@ -79,23 +79,23 @@ def foo1(): y = 14 for name, item in globals().items(): - print name, `item` + print(name, "item") alert ("Hello from AXCode") - print "Y is ",y + print("Y is ", y) def PythonGlobalFunction(): window.alert("Hello from Python - Im about to call JScript!") window.JScriptFunction() def Window_OnLoad(): - print "X is", x - print "a is", a -# print "------ GLOBALS ----------" + print("X is", x) + print("a is", a) +# print("------ GLOBALS ----------") # for n,v in globals().items(): -# print n,'=',v - print "MyForm is", MyForm - print "MyForm is repr", `MyForm` - print "MyForm.Button1 is", `MyForm.Button1` +# print(n, '=', v) + print("MyForm is", MyForm) + print("MyForm is repr", "MyForm") + print("MyForm.Button1 is", "MyForm.Button1") MyForm.Button1.Value = "Python Rules!" Form2.Button1.value = "Form2!" MyForm.Text1.value = document.location diff --git a/com/win32comext/axscript/demos/client/ie/mousetrack.htm b/com/win32comext/axscript/demos/client/ie/mousetrack.htm index d307a4a6fe..fee059b906 100644 --- a/com/win32comext/axscript/demos/client/ie/mousetrack.htm +++ b/com/win32comext/axscript/demos/client/ie/mousetrack.htm @@ -20,7 +20,7 @@