2

I want to create a startup configuration that runs a file that I request. So far, my configuration file is as follows:

path1=input('What folder would you like to open?')

os.chdir('C:\\Users\\Owner\\Documents\\Spring 2013\\CSCI_278\\'+path1)

doc=input('What file would  you like to open and run?')

open(doc)

execfile(doc)

but the execfile doesn't work for some reason, and I end having to use %run in pylab anyway. Is there a way around this?

Tim M.
  • 53,671
  • 14
  • 120
  • 163

1 Answers1

0

Does using raw_input instead of input solve your problem?

Not sure you need the open(doc) line.

The code below works on my machine:

doc = raw_input('What file would  you like to open and run?')

execfile(doc)

Note that you can also use the line below instead, if you do not want to type the ".py" each time

doc = "%s.py" % raw_input('What file would  you like to open and run?')
gcalmettes
  • 8,474
  • 1
  • 32
  • 28