Skip to content

Commit

Permalink
list2dict is the same as dict.fromkeys (#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Feb 24, 2025
1 parent e63c1a1 commit 0ae7ed1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Pythonwin/pywin/scintilla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,6 @@ def SaveTextFile(self, filename, encoding=None):
return 1

def _AutoComplete(self):
def list2dict(l):
ret = {}
for i in l:
ret[i] = None
return ret

self.SCIAutoCCancel() # Cancel old auto-complete lists.
# First try and get an object without evaluating calls
ob = self._GetObjectAtPos(bAllowCalls=0)
Expand All @@ -480,17 +474,19 @@ def list2dict(l):
# extra attributes of win32ui objects
if hasattr(ob, "_obj_"):
try:
items_dict.update(list2dict(dir(ob._obj_)))
items_dict.update(dict.fromkeys(dir(ob._obj_)))
except AttributeError:
pass # object has no __dict__

# normal attributes
try:
items_dict.update(list2dict(dir(ob)))
items_dict.update(dict.fromkeys(dir(ob)))
except AttributeError:
pass # object has no __dict__
if hasattr(ob, "__class__"):
items_dict.update(list2dict(_get_class_attributes(ob.__class__)))
items_dict.update(
dict.fromkeys(_get_class_attributes(ob.__class__))
)
# The object may be a COM object with typelib support - let's see if we can get its props.
# (contributed by Stefan Migowsky)
try:
Expand Down

0 comments on commit 0ae7ed1

Please sign in to comment.