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() It would look like this: suffix = [(".exe", "rb", 0)] file, path, descr = imp.find_module("wininst", __path__, suffix) data = file.read() file.close() return data Note that for a zip file, __file__ is something like C:/Python/lib/zarchive.zip/subdir/mymod.pyc and nothing is going to make code using __file__ Just Work. Well, maybe you could strip the last component "mymod.pyc" and use it as __path__ in a call to imp.find_module(). Not too hard, and it works with files and zip archives. But maybe not with future ftp:// imported modules. Your code knows the directory. My version would search in your package __path__ for it. But you only have one wininst.exe per package, right? And maybe putting it on package path is a feature. JimA
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