Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

name 'Graph' is not defined

Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:

def create_graph():
G = Graph()
G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
return G

When I create a new Sage file and try to call it, the following error appears. Why is this happening?

from zg import create_graph
create_graph()

NameError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 create_graph()

File /mnt/d/sage_z/new_fun/common_z.py:81, in create_graph()
     80 def create_graph():
---> 81     G = Graph()
     82     G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
     83     return G

NameError: name 'Graph' is not defined

name 'Graph' is not defined

Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:

def create_graph():
G = Graph()
G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
return G

When I create a new Sage file and try to call it, the following error appears. Why is this happening?

from zg import create_graph
create_graph()

NameError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 create_graph()

File /mnt/d/sage_z/new_fun/common_z.py:81, /mnt/d/sage_zhang/new_fun/common_z.py:81, in create_graph()
     80 def create_graph():
---> 81     G = Graph()
     82     G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
     83     return G

NameError: name 'Graph' is not defined

image description

name 'Graph' is not defined

Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:

def create_graph():
 G = Graph()
 G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
 return G

When I create a new Sage file and try to call it, the following error appears. Why is this happening?

from zg import create_graph
create_graph()

NameError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 create_graph()

File /mnt/d/sage_zhang/new_fun/common_z.py:81, in create_graph()
     80 def create_graph():
---> 81     G = Graph()
     82     G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
     83     return G

NameError: name 'Graph' is not defined

image description

name 'Graph' is not defined

Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:

def create_graph():
    G = Graph()
    G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
    return G

When I create a new Sage file and try to call it, the following error appears. Why is this happening?

from zg import create_graph
create_graph()

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[7], In[4], line 1
2
      1 from zg import create_graph
----> 1 2 create_graph()

File /mnt/d/sage_zhang/new_fun/common_z.py:81, /mnt/d/sage_zhang/new_fun/zg.py:2, in create_graph()
     80  1 def create_graph():
---> 81 ----> 2     G = Graph()
     82  3     G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
     83  4     return G

NameError: name 'Graph' is not defined

image description

name 'Graph' is not defined

Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:

def create_graph():
    G = Graph()
    G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
    return G

When I create a new Sage file and try to call it, the following error appears. Why is this happening?happening? Can't Sage's own functions be used in zg.py?

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[4], line 2
      1 from zg import create_graph
----> 2 create_graph()

File /mnt/d/sage_zhang/new_fun/zg.py:2, in create_graph()
      1 def create_graph():
----> 2     G = Graph()
      3     G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
      4     return G

NameError: name 'Graph' is not defined

image description