-1

As the topic says..

I want to use the file

indata.txt:

f=lambda x,y:-2*x*y
xa=0
xb=2
A=2 
n=18

Into my big program:

from math import *

'''Function which calculates the d.e. using runge-kuttas formula'''
def runge(f,xa,xb,A,n):
    .....



indata=open("indata.txt","r")
runge(f,xa,xb,A,n)
indata.close()

So my question is: How to I use the variables in the text file indata.txt as input to the bigger program?

Aerdennis
  • 1
  • 1

1 Answers1

0

As I know, you could use one of two options:
1. Rename your file to inpdata.py as mentioned in comments and in your main file use

from inpdata import *
  1. Use built in python execfile() function. For Python3 execfile() alternative look here.
Community
  • 1
  • 1
kvorobiev
  • 5,012
  • 4
  • 29
  • 35