2

I have two files the first one is an ipynb file :

code_A.ipynb

x = 10

def square(y):

  return y**2

and another python file :

code_B.py

py_file_location = "/content/drive/MyDrive/Colab Notebooks"

sys.path.append(os.path.abspath(py_file_location))

from resources.code_A import *

result = x + 2

print('final result ', square(result))

The two codes are stored in the same file.

How can I get variables values and functions from the ipynb file to the python file.

Error

NameError: name 'code_A' is not defined
SamBn04
  • 151
  • 1
  • 7

0 Answers0