Thomas Heller wrote: > But then, how would this (working) code have to be written with the > new imp.find_module() function: > > def get_exe_bytes (self): > # wininst.exe is in the same directory as this file > directory = os.path.dirname(__file__) > filename = os.path.join(directory, "wininst.exe") > return open(filename, "rb").read() With the importer protocol (as I imagine it now, this doesn't match zipimporter's current behavior yet) it could be written like this: def get_exe_bytes (self): if os.path.isfile(__file__): # wininst.exe is in the same directory as this file directory = os.path.dirname(__file__) filename = os.path.join(directory, "wininst.exe") return open(filename, "rb").read() else: path = __name__.replace(".", os.sep) + os.sep + \ "wininst.exe" return __importer__.get_data(path) Just PS: please take care to not Cc to peps@python.org any more in this thread, I think I've done enough harm ;-)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4