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 cc17445e9a..405107e65d 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 bbe1369e48..b7a3f639f1 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 320e34ddf5..33c3bf0884 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 7fd965327d..ff174d168f 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 4aacc0eab5..7a09941786 100644 --- a/Pythonwin/pywin/framework/editor/color/coloreditor.py +++ b/Pythonwin/pywin/framework/editor/color/coloreditor.py @@ -474,7 +474,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 63df9cfcdb..c90b7f7e70 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -268,7 +268,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 06fbcc82b0..273c2b4af3 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 16bff7fa8a..8d689b89ce 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 b1db509316..a88e7158d4 100644 --- a/Pythonwin/pywin/scintilla/IDLEenvironment.py +++ b/Pythonwin/pywin/scintilla/IDLEenvironment.py @@ -551,7 +551,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 910161bad4..c5f7b4dc84 100644 --- a/Pythonwin/pywin/scintilla/view.py +++ b/Pythonwin/pywin/scintilla/view.py @@ -690,7 +690,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!) @@ -778,7 +787,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 4f27da9a91..07f8494eef 100644 --- a/Pythonwin/pywin/tools/hierlist.py +++ b/Pythonwin/pywin/tools/hierlist.py @@ -221,9 +221,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 @@ -233,7 +233,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): @@ -244,7 +244,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 b94d3050fb..3d9d3a1818 100644 --- a/Pythonwin/pywin/tools/regedit.py +++ b/Pythonwin/pywin/tools/regedit.py @@ -163,9 +163,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 a7309642a9..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',string.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:',string.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 77415bc1d9..7cbf419cb8 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 6e23e70540..a6dda80e63 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 449ad928fd..599f154308 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 1d9ca3300d..31ba6c2c48 100644 --- a/com/win32com/client/gencache.py +++ b/com/win32com/client/gencache.py @@ -457,7 +457,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( @@ -466,7 +466,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] @@ -524,7 +524,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) @@ -549,21 +549,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 @@ -597,7 +597,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 96997d3a29..433fc50823 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 178ab7adc8..57f2ff94ee 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 9639c1395a..ccee1448a0 100644 --- a/com/win32com/test/testCollections.py +++ b/com/win32com/test/testCollections.py @@ -99,10 +99,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 b41a44726a..d2babb0845 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 1704f63267..0c74a4180e 100644 --- a/com/win32com/test/util.py +++ b/com/win32com/test/util.py @@ -59,7 +59,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: @@ -87,7 +87,7 @@ def RegisterPythonServer(filename, progids=None, verbose=0): cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename) 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 f7d86e4dde..f1ce8f416b 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( "Interface '%s' does not exist in this cached typelib" % (name,) ) - # 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/axdebug/adb.py b/com/win32comext/axdebug/adb.py index 812c23e62a..7c22af2e22 100644 --- a/com/win32comext/axdebug/adb.py +++ b/com/win32comext/axdebug/adb.py @@ -321,7 +321,7 @@ def ResetAXDebugging(self): return if len(self.recursiveData) == 0: - # print "ResetAXDebugging called for final time." + # print("ResetAXDebugging called for final time.") self.logicalbotframe = None self.debuggingThread = None self.currentframe = None diff --git a/com/win32comext/axdebug/codecontainer.py b/com/win32comext/axdebug/codecontainer.py index be20a2d394..212316a790 100644 --- a/com/win32comext/axdebug/codecontainer.py +++ b/com/win32comext/axdebug/codecontainer.py @@ -78,9 +78,9 @@ def GetLineOfPosition(self, charPos): lastOffset = lineOffset lineNo = lineNo + 1 else: # for not broken. - # print "Cant find", charPos, "in", self.lineOffsets + # print("Cant find", charPos, "in", self.lineOffsets) raise Exception(scode=winerror.S_FALSE) - # print "GLOP ret=",lineNo, (charPos-lastOffset) + # print("GLOP ret=",lineNo, (charPos-lastOffset)) return lineNo, (charPos - lastOffset) def GetNextLine(self): @@ -269,8 +269,8 @@ def GetName(self, dnt): if attrlen != len(text): print("Lengths dont match!!! (%d/%d)" % (attrlen, len(text))) - # print "Attributes:" - # print attrs + # print("Attributes:") + # print(attrs) print("GetLineOfPos=", sc.GetLineOfPosition(0)) print("GetLineOfPos=", sc.GetLineOfPosition(4)) print("GetLineOfPos=", sc.GetLineOfPosition(10)) diff --git a/com/win32comext/axdebug/debugger.py b/com/win32comext/axdebug/debugger.py index 3157586bce..f8b1a539ed 100644 --- a/com/win32comext/axdebug/debugger.py +++ b/com/win32comext/axdebug/debugger.py @@ -50,9 +50,9 @@ def BuildModule(module, built_nodes, rootNode, create_node_fn, create_node_args) ".pyd", ".dll", ] - # keep = keep and module.__name__=='__main__' + # keep = keep and module.__name__=='__main__' if module and keep: - # print "keeping", module.__name__ + # print("keeping", module.__name__) node = ModuleTreeNode(module) built_nodes[module] = node realNode = create_node_fn(*(node,) + create_node_args) @@ -92,12 +92,12 @@ def __init__(self, axdebugger): self.axdebugger.RefreshAllModules(self.nodes, self) def FromFileName(self, fname): - ### It appears we cant add modules during a debug session! - # if self.currentNumModules != len(sys.modules): - # self.axdebugger.RefreshAllModules(self.nodes, self) - # self.currentNumModules = len(sys.modules) - # for key in self.ccsAndNodes.keys(): - # print "File:", key + # It appears we cant add modules during a debug session! + # if self.currentNumModules != len(sys.modules): + # self.axdebugger.RefreshAllModules(self.nodes, self) + # self.currentNumModules = len(sys.modules) + # for key in self.ccsAndNodes.keys(): + # print("File:", key) return documents.CodeContainerProvider.FromFileName(self, fname) def Close(self): diff --git a/com/win32comext/axdebug/documents.py b/com/win32comext/axdebug/documents.py index 2bcc1c6f14..d097813a01 100644 --- a/com/win32comext/axdebug/documents.py +++ b/com/win32comext/axdebug/documents.py @@ -121,8 +121,8 @@ def AddCodeContainer(self, cc, node=None): def FromFileName(self, fname): cc, node = self.ccsAndNodes.get(GetGoodFileName(fname), (None, None)) - # if cc is None: - # print "FromFileName for %s returning None" % fname + # if cc is None: + # print(f"FromFileName for {fname} returning None") return cc def Close(self): diff --git a/com/win32comext/axdebug/expressions.py b/com/win32comext/axdebug/expressions.py index e573eb514e..8a65fa93aa 100644 --- a/com/win32comext/axdebug/expressions.py +++ b/com/win32comext/axdebug/expressions.py @@ -33,7 +33,7 @@ def ParseLanguageText(self, code, radix, delim, flags): ) def GetLanguageInfo(self): - # print "GetLanguageInfo" + # print("GetLanguageInfo") return "Python", "{DF630910-1C1D-11d0-AE36-8C0F5E000000}" @@ -78,7 +78,7 @@ def QueryIsComplete(self): return self.isComplete def GetResultAsString(self): - # print "GetStrAsResult returning", self.result + # print("GetStrAsResult returning", self.result) return self.hresult, MakeNiceString(self.result) def GetResultAsDebugProperty(self): diff --git a/com/win32comext/axdebug/stackframe.py b/com/win32comext/axdebug/stackframe.py index edc3fe8cb8..fd8d20e4ca 100644 --- a/com/win32comext/axdebug/stackframe.py +++ b/com/win32comext/axdebug/stackframe.py @@ -21,9 +21,9 @@ class EnumDebugStackFrames(gateways.EnumDebugStackFrames): def __init__(self, debugger): infos = [] frame = debugger.currentframe - # print "Stack check" + # print("Stack check") while frame: - # print " Checking frame", frame.f_code.co_filename, frame.f_lineno-1, frame.f_trace, + # print(" Checking frame", frame.f_code.co_filename, frame.f_lineno-1, frame.f_trace) # Get a DebugCodeContext for the stack frame. If we fail, then it # is not debuggable, and therefore not worth displaying. cc = debugger.codeContainerProvider.FromFileName(frame.f_code.co_filename) @@ -31,7 +31,7 @@ def __init__(self, debugger): try: address = frame.f_locals["__axstack_address__"] except KeyError: - # print "Couldnt find stack address for",frame.f_code.co_filename, frame.f_lineno-1 + # print("Couldnt find stack address for",frame.f_code.co_filename, frame.f_lineno-1) # Use this one, even tho it is wrong :-( address = axdebug.GetStackAddress() frameInfo = ( @@ -42,23 +42,23 @@ def __init__(self, debugger): None, ) infos.append(frameInfo) - # print "- Kept!" - # else: - # print "- rejected" + # print("- Kept!") + # else: + # print("- rejected") frame = frame.f_back gateways.EnumDebugStackFrames.__init__(self, infos, 0) - # def __del__(self): - # print "EnumDebugStackFrames dieing" + # def __del__(self): + # print("EnumDebugStackFrames dieing") def Next(self, count): return gateways.EnumDebugStackFrames.Next(self, count) - # def _query_interface_(self, iid): - # from win32com.util import IIDToInterfaceName - # print "EnumDebugStackFrames QI with %s (%s)" % (IIDToInterfaceName(iid), str(iid)) - # return 0 + # def _query_interface_(self, iid): + # from win32com.util import IIDToInterfaceName + # print(f"EnumDebugStackFrames QI with {IIDToInterfaceName(iid)} ({iid})") + # return 0 def _wrap(self, obj): # This enum returns a tuple, with 2 com objects in it. obFrame, min, lim, fFinal, obFinal = obj @@ -75,8 +75,8 @@ def __init__(self, frame, lineno, codeContainer): self.codeContainer = codeContainer self.expressionContext = None - # def __del__(self): - # print "DSF dieing" + # def __del__(self): + # print("DSF dieing") def _query_interface_(self, iid): if iid == axdebug.IID_IDebugExpressionContext: if self.expressionContext is None: @@ -85,8 +85,8 @@ def _query_interface_(self, iid): axdebug.IID_IDebugExpressionContext, ) return self.expressionContext - # from win32com.util import IIDToInterfaceName - # print "DebugStackFrame QI with %s (%s)" % (IIDToInterfaceName(iid), str(iid)) + # from win32com.util import IIDToInterfaceName + # print(f"DebugStackFrame QI with {IIDToInterfaceName(iid)} ({iid})") return 0 # @@ -133,8 +133,8 @@ def __init__(self, debugger): self.debugger = debugger trace("DebugStackFrameSniffer instantiated") - # def __del__(self): - # print "DSFS dieing" + # def __del__(self): + # print("DSFS dieing") def EnumStackFrames(self): trace("DebugStackFrameSniffer.EnumStackFrames called") return _wrap( diff --git a/com/win32comext/axdebug/util.py b/com/win32comext/axdebug/util.py index c3d4f733f6..85affbfd7a 100644 --- a/com/win32comext/axdebug/util.py +++ b/com/win32comext/axdebug/util.py @@ -97,7 +97,7 @@ def __init__(self, policyClass, object): win32com.server.policy.DispatcherTrace.__init__(self, policyClass, object) import win32traceutil # Sets up everything. - # print "Object with win32trace dispatcher created (object=%s)" % `object` + # print(f"Object with win32trace dispatcher created (object={object})") def _QueryInterface_(self, iid): rc = win32com.server.policy.DispatcherBase._QueryInterface_(self, iid) @@ -119,7 +119,7 @@ def _Invoke_(self, dispid, lcid, wFlags, args): rc = win32com.server.policy.DispatcherBase._Invoke_( self, dispid, lcid, wFlags, args ) - # print "Invoke of", dispid, "returning", rc + # print("Invoke of", dispid, "returning", rc) return rc except Exception: t, v, tb = sys.exc_info() diff --git a/com/win32comext/axscript/client/debug.py b/com/win32comext/axscript/client/debug.py index b3871ab19c..d7bdf00530 100644 --- a/com/win32comext/axscript/client/debug.py +++ b/com/win32comext/axscript/client/debug.py @@ -102,7 +102,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 85021c4488..3d98bd839c 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: @@ -761,7 +772,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 @@ -1048,7 +1059,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 @@ -1075,7 +1086,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 7c7fb48d40..fc6e78539d 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 @@