How to find out if the interpreter is a debug build?
"Martin v. Löwis"
martin at v.loewis.de
Sat Sep 1 02:25:25 EDT 2007
llothar schrieb:
> How can i find out if a selected python interpreter (i only know the
> path name under which i should start it) is a debug build? I tried
>
> sys.api_version, sys.platform, sys.version, sys.version_info
>
> and there is no difference between "python.exe" and "python_d.exe".
Sure there is:
if sys.executable.endswith("_d.exe"):
print "Debug version"
If relying on the executable name is too unsafe, you can also look
at imp.get_suffixes(), which includes "_d.pyd" in a debug build on
Windows.
If you want it cross-platform, you can check whether sys.getobjects
is available. That, of course, is also unsafe because there isn't
a single "debug build" on Unix, but instead, several debugging
features can be enabled and disabled separately, so you would have
to specify first what precisely a debug build is.
Regards,
Martin
More information about the Python-list
mailing list