Executing Python code with imported scripts directly from GitHub on Sage Cell

13 views
Skip to first unread message

Elimboto Yohana

unread,
Apr 21, 2024, 11:52:45 AMApr 21
to Andrey Novoseltsev, sage-cell
Hello Community,

I am seeking assistance on how to run Python codes with imported scripts directly from GitHub on Sage Cell. Typically, it is possible to execute a single script by using the raw content path, as shown below:

load("https://raw.githubusercontent.com/xxxxxxxxxxxxxx")

I am now exploring how to execute a Python code with imported scripts, as demonstrated in the example below:

graphs.py:

class Plotting:
    def __init__(self):
        #Import the module containing the plot_line function
        import plotting_line

    def plot_bar(self, data):
        #Call the plot_line function from the imported module
        plotting_line.plot_line(data)

plotting_line.py:

def plot_line(data):
    #Do something to plot a line graph with data
    print("Creating line plot with data:", data)

#Create an instance of the Plotting class
plotter = Plotting()
plotter.plot_bar([1, 2, 3, 4, 5])  #Call the plot_bar method with a list of data

I would greatly appreciate any help or guidance on how to achieve this.

Kind regards,
Elimboto
Reply all
Reply to author
Forward
0 new messages