[Python-Dev] Complex detection
Tim Peters
tim.one@home.com
Fri, 13 Apr 2001 18:48:22 -0400
[Paul F. Dubois]
> My understanding is that Python can be built without complex numbers
> to satisfy the needs of the Python-on-a-wristwatch crowd. Is there a
> run-time way to tell? For example, using an imaginary literal causes
> an error? If so, what kind?
You can find out by compiling with WITHOUT_COMPLEX #define'd. PythonLabs
never does this, so no guarantee it even works. I'm not going to bother
starting now, either <wink>. Based on skimming the code, I expect
try:
eval("1j")
with_complex = 1
except SyntaxError:
with_complex = 0
would do the trick, but no guarantee.