# Revision history [back]

### Programming with Sage: defining module

Let's say I want to write two modules 'addition.sage' and 'result.sage'.
I would like to import 'addition.sage' in 'result.sage'. How can I do this?
I've try the following, but it doesn't seem to work.

from sage.all import *

'result.sage' file:

my sage session:

This gives me the error 'ImportError: No module named addition'.
Although, my PYTHONPATH contains the directory where my two modules are located.

### Programming with Sage: defining module

Let's say I want to write two modules 'addition.sage' and 'result.sage'.
I would like to import 'addition.sage' in 'result.sage'. How can I do this?
I've try the following, but it doesn't seem to work.

from sage.all import * *
add(x,y)=x+y add(x,y)=x+y

'result.sage' file:
from addition import add add
print add(1,2) add(1,2)

my sage session:
sage: load('myPath/result.sage')

This gives me the error 'ImportError: No module named addition'.
Although, my PYTHONPATH contains the directory where my two modules are located.

 3 retagged Shashank 1887 ●24 ●45 ●80

### Programming with Sage: defining module

Let's say I want to write two modules 'addition.sage' and 'result.sage'.
I would like to import 'addition.sage' in 'result.sage'. How can I do this?
I've try the following, but it doesn't seem to work.

from sage.all import *
add(x,y)=x+y
from addition import add
print add(1,2)
sage: load('myPath/result.sage')