Run Python (MAC)-Overview __python

Source: Internet
Author: User
Tags sublime text
run Python (MAC)-Overview

You should now have the Python 2.7.9 or later installed on your Mac computer. Here, we'll outline two ways to run Python on a computer. In the pages that follow, you can find a more detailed description of each method. We strongly recommend that you be familiar with both approaches. Method 1: Using a text editor

In the previous phase of this nano-degree, you used a text editor to write HTML and CSS code, and to save the code to the appropriate file type by selecting the extension. html and. css. At this stage of the Nano degree, you will use your text editor to write Python code and save it as a file type with a. py extension, such as test.py.

Many text editors provide a handy feature that allows us to run code inside a text editor program and receive its output. In some editors (such as Sublime Text), this process is simple, just save the file as a file with a. py extension, and then request the editor to run ("Run" or "build") code. On the next page, you'll find a more detailed description of two common text editors Sublime text and Atom running Python code. If you are using a different editor and want to implement this feature, you can search Google for instructions on how to do this, or visit the Udacity forum for help. Method 2: Use the command line

It may be convenient to run and display Python's output using a text editor, but most developers also know how to run code using the command line. This process still starts with writing and saving code from a text editor, but instead of requiring the text editor to run or build the code, run our Python file by entering a line of commands in the command-line interface (command line interface abbreviation CLI). What is the command line interface (CLI).

The command-line interface (CLI) is a text-based window in which you can enter commands to the computer and then receive some output. You can see it as a direct conversation between a computer and its users.

The CLI we will use on Macs is accessed by running an application named Terminal (Terminal). When you open the terminal, you will enter a CLI called the shell. There are many different kinds of shells, and in Mac, the default type is bash. In this shell environment, the user enters a text command, the keyboard clicks the return key to run the command, and receives the response or output after the computer completes the instruction. (Translator note: Shell literal meaning "shell", corresponds to the kernel (kernel), this is understood as "command interpreter", is the interface that user interacts with system kernel, user enters corresponding standard command, the shell completes the operation that the user needs by parsing the command, response or output. The syntax for different kinds of shells is slightly different. Why use the CLI to run code.

Using a command-line interface to execute a command is efficient because it does not rely on any graphical user interface (GUI), and users do not have to click through the Windows menu, or preset buttons and icons. Understanding the shell is even necessary for developers who need to log on to a remote server that has a usable shell rather than a GUI. In addition, writing a shell command (or the process of writing a shell script) can provide developers with high flexibility and power-for example, a single line of commands can create, move, or delete a large number of files, or perform various complex tasks. Finally, it is a useful skill to simply browse the computer and execute commands via the CLI. Now invest time in learning how to use the command line, which will save you a lot of time later. How to access the CLI on the Mac.

On the MAC, you will use the terminal application to access the command line. In the next page, you'll find detailed instructions for running Python code using a terminal.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.