Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,8 @@ def __dir__(self):
def __repr__(self):
# Need to get the docstring for the module for this class.
try:
mod_doc = sys.modules[self.__class__.__module__].__doc__
if mod_doc:
mod_name = "win32com.gen_py." + mod_doc
else:
mod_name = sys.modules[self.__class__.__module__].__name__
module = sys.modules[self.__class__.__module__]
mod_name = "win32com.gen_py." + (module.__doc__ or module.__name__)
except KeyError:
mod_name = "win32com.gen_py.unknown"
return f"<{mod_name}.{self.__class__.__name__} instance at 0x{id(self)}>"
Expand Down Expand Up @@ -630,7 +627,7 @@ def __init__(self, oobj=None):
self.__dict__["_dispobj_"] = self.default_interface(oobj)

def __repr__(self):
return f"<win32com.gen_py.{__doc__}.{self.__class__.__name__}>"
return f"<{self.__class__.__module__}.{self.__class__.__name__}>"

def __getattr__(self, attr):
d = self.__dict__["_dispobj_"]
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __bool__(self):
# desirable???

def __repr__(self):
return "<COMObject %s>" % (self._username_)
return f"<COMObject {self._username_}>"

def __str__(self):
# __str__ is used when the user does "print(object)", so we gracefully
Expand Down
9 changes: 2 additions & 7 deletions com/win32comext/axscript/client/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(self):
self.name = "<None>"

def __repr__(self):
return "<%s at %d: %s>" % (self.__class__.__name__, id(self), self.name)
return f"<{self.__class__.__name__} at {id(self)}: {self.name}>"

def Reset(self):
pass
Expand Down Expand Up @@ -318,12 +318,7 @@ def __repr__(self):
flagsDesc = ""
if self.flags is not None and self.flags & axscript.SCRIPTITEM_GLOBALMEMBERS:
flagsDesc = "/Global"
return "<%s at %d: %s%s>" % (
self.__class__.__name__,
id(self),
self.name,
flagsDesc,
)
return f"<{self.__class__.__name__} at {id(self)}: {self.name}{flagsDesc}>"

def _dump_(self, level):
flagDescs = []
Expand Down
7 changes: 2 additions & 5 deletions win32/Lib/win32timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,8 @@ def _LoadDynamicInfoFromKey(self, key) -> None:
)

def __repr__(self) -> str:
result = f"{self.__class__.__name__}({self.timeZoneName!r}"
if self.fixedStandardTime:
result += ", True"
result += ")"
return result
fix_standard_time = ", True" if self.fixedStandardTime else ""
return f"{self.__class__.__name__}({self.timeZoneName!r}{fix_standard_time})"

def __str__(self) -> str:
return self.displayName
Expand Down