Tuesday, 15 February 2011

windows - AttributeError: 'module' object has no attribute 'testmod' Python doctest -


Whenever I try to work in Python, basically whenever I run the code

  <___name__ == "__ main__": import malicious doctest.testmod ()  

I get this response from interpreter

Features: 'module' object There is no attribute in 'testmod'

I can run this code just fine, but whenever I run it on my Windows machine, it does not work

My machine is running OS X, but Python runs 2.7.5.

thanks :)

It seems to be importing instead of standard code There is a separate module named doctest

To find out which module is being imported properly, just click the following print To add:

  if __name__ == "__ main__": import doctest print doctest .__ file__ #adding this doctest.testmod  

Print should produce something similar to C: \ Python27 \ lib \ doctest.pyc , the Python being used Any other output based on the location and version of that means you are importing the wrong module, and tell you why you got the error.


No comments:

Post a Comment