[Tutor] crash when importing random or sys module, in my embedded python

R. Alan Monroe R. Alan Monroe" <amonroe@columbus.rr.com
Wed Jun 18 19:01:01 2003


What kinds of things can go wrong during an import statement OTHER
THAN an ImportError?

When I run this in my embedded python program, it takes the second
option and writes "who knows" to the log. Sadly import sys crashes
too, so I can't use sys.exc_info(). The weird thing is, import struct
works like a champ?




import struct

try:
    import random
except ImportError, e:
    log = open('/badnews.txt', 'w')
    log.write(e.args)
    log.close()
except:
    log = open('/badnews.txt', 'w')
    log.write("who knows\n")
    log.close()