Wie schaffe ich das dass man von einem Modul nur eine bestimmte Variable in einem anderen Modul importiert
Code: Alles auswählen
# liveplot.py
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
global xs
def animate(i):
lines = open('live.txt','r').read().split('\n')
xs = []
ys = []
for line in lines:
if len(line) > 1:
x, y = line.split(',')
xs.append(x)
ys.append(y)
ax1.clear()
ax1.plot(xs, ys)
ani = animation.FuncAnimation(fig, animate, interval = 1000)
plt.show()
Code: Alles auswählen
from liveplot import xs
print(liveplot.xs)
die variable xs importiert wird vom modul "liveplot".....