Importing

So I am wondering where exactly do I find information on importing stuff? I have looked through the API and still cannot figure out where the math class comes from

On top of that I do not know when to use

Import

or

From

Could someone help me out?

Math is a python “library”(i dont know whats the right name).

if you tipe import mymodule you can acces things inside of this module by tiping mymodule.things.
if you tipe from mymodule import AThing
you can acces AThing by tiping AThing
By tiping from mymodule import * you can acces all things in the file directly

Sounds like it would be helpful to do some more studying of the Python language. www.python.org can be your friend.

math is a standard Python module. It has nothing to do with Panda3D.

There are several different ways to import the symbols from a module. All are equally good, but they have slightly different effects. If the module “Module” defines symbols “A” and “B”, then:


from Module import A

makes A available, but not B.


from Module import *

makes both A and B available (as well as everything else defined in the module).


import Module

makes Module.A and Module.B available.

In our Panda3D code, we often have a class defined the same name as the module it is in, for instance, in the Actor module you’ll find a class named Actor. So you can do:


from Actor import Actor

To reference a class named Actor
or


import Actor

To reference a class named Actor.Actor

David