Many games require the saving and loading of files or other similar uses of data that is impractical to include in the code itself. Python has its own file input/output module, and the makers of Panda3D have included a similar, thread-safe module that we can use for file I/O in Panda3D applications. We can import it with this line:
from direct.stdpy.file import *
The interface for
direct.stdpy.file is identical to the Python interface, and since this book is intended for those already familiar with Python, we won't spend a lot of time explaining this interface. We will talk a little bit about it just to illustrate its use in Panda3D.
To open a file, we use the
open function. We need to give this function the filename and path as its ...