Tebe
Tebe

Reputation: 3214

python importing module, find out what is exactly wrong

I try to import a module.

# coding: utf-8
import rb

def main():
  print "working"

if __name__ == "__main__":
  main()

if "import" directive is present, program prints nothing
and I get:

enter image description here

Echo $? shows that program worked correctly.
How can one check whether module was correctly loaded?

P.S. It seems that this module is present in the directory,
because if I delete all another files except interpreted script, I get:

Thanks in advance!

Upvotes: 0

Views: 119

Answers (2)

Cédric Julien
Cédric Julien

Reputation: 80751

In the rb.py file, there is a funny line at the end : sys.stdout = _rbdebugfile(sys.stdout.fileno()), this will redirect the standard stdout (where the printed characters go) to a special file instead of the console.

The lost characters are in the file created by rb.py.

Upvotes: 1

Jiminion
Jiminion

Reputation: 5168

Delete this line from rb.py:

sys.stdout = _rbdebugfile(sys.stdout.fileno())

Upvotes: 1

Related Questions