Arcade Prehacks

Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    Feb 2010
    Location
    http://tinyurl.com/2atap49
    Posts
    2,328

    [HELP]Open a python file using a python file

    Not just opening some file automatically, that's easy. I want to know how to make a "enter program" function and it opens the program
    My current code is this:
    Code:
    g='Prime Number Finder'
    i=import program1 
    program1 = prime_numbers.py.environ.get('Prime_numbers')
    if program1 and prime_numbers.path.isfile(filename):
        execfile(prime_numbers.py)
    
    print 'Programs available:'
    print '1.', g
    a=int(raw_input("Enter the program number: "))
    while True:
    	ok = raw_input(prompt)
    	if ok in ('1'):
    		return i
    while True:
    	pass
    But I get a syntax error saying
    Code:
    i=import program1
    ^
    SyntaxError: invalid syntax
    How do I fix it?


    --Additional Info--
    *the file I'm trying to open is named prime_numbers.py
    **prime_numbers.py is in a folder that run.py(the code above) is not in
    Um... I used to be a moderator here...

  2. #2
    RedFaceofAwesomeness's Avatar
    Join Date
    Dec 2010
    Location
    New York
    Posts
    621

    Re: [HELP]Open a python file using a python file

    What is python file used for exactly.

  3. #3
    Senior Member
    Join Date
    Feb 2010
    Location
    http://tinyurl.com/2atap49
    Posts
    2,328

    Re: [HELP]Open a python file using a python file

    Quote Originally Posted by LOLface
    What is python file used for exactly.
    Anything you program it to do.
    Python is a programming language, and that's exactly what I tend to do with it

    Edit: I got help from someone now, request lock
    Um... I used to be a moderator here...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •