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 @@
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 @@
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))
@@ -137,11 +137,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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.
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 @@