Thanks for your answers! I prefer the proposal of Thomas Heller by using a small helper function like this:
def IsDebugVersionRunning(): import imp for suffix in imp.get_suffixes(): if suffix[0] == '_d.pyd': return True return False This works well for me. The _ctypes.__file__ trick didn't work for me - I guess I've done something wrong... One more question: Under linux this doesn't seam to work - as there is always returned '.so' (not '_d.so') at least in my tests. Are there no debug/release version issues like on windows? doesn't import the python2.4-dbg (debian) binary different modules than python2.4? Raphael Zulliger Thomas Heller wrote: > Raphael Zulliger schrieb: > >> Hi >> >> I have to check wheter a .py script is run within the debug or the >> release version of an embedded python interpreter (in short, wheter >> python24_d.dll or python24.dll is in use). >> >> long version: I'm using ctypes to load my own dll. There exists 2 >> version of this dll - a debug and a release version (where one is >> linked against debug C runtime dll and the other to release C runtime >> dll). Now >> I have to change the name of the dll I want to be loaded by ctypes... >> But how can I find out which of the dll I have to load?! >> >> Thanks in advance! >> Raphael Zulliger > > > You could use imp.get_suffixes(). In a release build the returned list > will contain these entries > ('.pyd', 'rb', 3), ('.dll', 'rb', 3) > in a debug build that will be > ('_d.pyd', 'rb', 3), ('_d.dll', 'rb', 3) > > Another way would be to look at the filename of any binary extension > module. _ctypes.__file__, for example: '.....\\_ctypes.pyd' vs. > '....\\_ctypes_d.pyd'. > > Thomas -- http://mail.python.org/mailman/listinfo/python-list