O'Reilly logo

Blender 2.49 Scripting by Michel J. Anders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The trouble with import

One of the questions that regularly pops up is why the import statement isn't working as expected. The problem here is that you have to know what to expect. Blender has augmented the standard import behavior of Python to make it possible to import from the text files residing within a .blend file. This is a great boon because it allows you to modularize your code without the need to distribute separate files. However, the behavior of the part that imports these internal files should be absolutely clear to spare you nasty surprises but it is, at the moment, not very well-documented.

This is what happens when an import statement such as import foo is executed:

  1. Check whether foo.pyc or foo.py exists in any of the directories ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required