How to exit interactive mode in Python

This is obviously very new, but I installed Python 2.7 and started reading the manual. However, I looked and looked, and could not figure out how to start programming a file, and not write interactively. One book that was suggested online by quit (), which is surprising - exit the program.

Should coding be done in another program? I am using IDLE (Python GUI). Can coding not run inside this program?

+3
source share
6 answers

Yes, encoding must be done in another program. The interactive shell is very useful, but it is not an editor.

+2
source

Python ( Python) , vim, emacs .. Python, script.

$ python myscript.py
+1

. , W:/mytest . .

Idle. :

import os
os.chdir("W:/mytest")

W:/mytest Idle.

import sys
sys.path.append(".")

, "", .

File/New Window, , File/Save As. Python, W:/mytest. () "test1.py".

test1.py :

""" test1.py is my test
"""

print ("This is test1.")

class Test1:
    def __init__(self):
        print ("Constructed")

, script .

, ; Idle "Python Shell". Python:

>>> execfile("test1.py")
This is test1.
>>> import test1
This is test1
>>> tt = test1.Test1()
Constructed
+1

new, script . , , , script, , .

, python , , , .

0

use the new window tool in the file icon, in the python run write a program

0
source

To start coding in a file, just open a new file and start typing.

-2
source

Source: https://habr.com/ru/post/1768923/


All Articles