SUBLIMEREPL Configuration Python3 Development

Source: Internet
Author: User

First of all, what is REPL?

A Read-eval-print-loop (REPL) is available both as a standalone program and easily includable in other programs. REPL provides a-interactively run JavaScript and see the results. It can be used to debugging, testing, or just trying things out.

The interactive interpreter (REPL) can be run as a standalone program or easily included in other programs as part of a whole program. REPL provides an interactive way to run JavaScript scripts and view running results, often repl interactive ways to debug, test, and experiment with some kind of idea.

An interactive command-line interface that understands execution, which is equivalent to a DOS interface shell.

Python is a language that supports REPL

Configure Run Python3.5

https://sublimerepl.readthedocs.io/en/latest/#installation

These are the documentation for the SUBLIMEREPL configuration Lua language

Imitate this to configure Python3.5

First Packages:browse package Find Sublimerepl folder, and then into the Config folder, you can see many language configuration files, Python is also in the inside

Create a new Python3.5 folder here, create a new default.sublime-commands and menu.sublime-menu two files in it (mimic Python folder) We Python3.5 now as long as we can open the shell to run, and run the script, two function, so just include Python3.5 and python3.5–run current file two.

The Default.sublime-commands configuration is as follows:

[

{

"caption": "sublimerepl:python3.5",

"Command": "Run_existing_window_command", "args":

{

"id": "repl_python3.5",

"File": "Config/python3.5/main.sublime-menu"

}

},

{

"caption": "Sublimerepl:python3.5-run current File",

"Command": "Run_existing_window_command", "args":

{

"id": "repl_python3.5_run",

"File": "Config/python3.5/main.sublime-menu"

}

}

]

The Menu.sublime-menu configuration is as follows:

[

{

"id": "Tools",

"Children":

[{

"caption": "Sublimerepl",

"Mnemonic": "R",

"id": "SUBLIMEREPL",

"Children":

[

{"caption": "Python3.5",

"id": "Python3.5",

"Children": [

{"Command": "Repl_open",

"caption": "Python3.5",

"id": "repl_python3.5",

"Mnemonic": "P",

"Args": {

"Type": "Subprocess",

"Encoding": "UTF8",

"cmd": ["python3.5", "-I", "-U"],

"CWD": "$file _path",

"Syntax": "Packages/python/python.tmlanguage",

"external_id": "python3.5",

"Extend_env": {"pythonioencoding": "Utf-8"}

}

},

Run files

{"Command": "Repl_open",

"caption": "Python3.5-run current File",

"id": "repl_python3.5_run",

"Mnemonic": "R",

"Args": {

"Type": "Subprocess",

"Encoding": "UTF8",

"cmd": ["python3.5", "-U", "$file _basename"],

"CWD": "$file _path",

"Syntax": "Packages/python/python.tmlanguage",

"external_id": "python3.5",

"Extend_env": {"pythonioencoding": "Utf-8"}

}

}

]}

]

}]

}

]

Note the ID in the Default.sublime-commands file and Menu.sublime-menu files in the same ID, Menu.sublime-menu caption is the menu bar level content, cmd content python3.5, is you directly in the Ubuntu Terminal command, The files in the Default.sublime-commands file point to the Menu.sublime-menu file, with the ID and file name, you can find the configuration of the corresponding command

After saving the file, you can run the command from the menu bar, tools->sublimerepl->python3.5

In order to be consistent with the ctrl+b operation, you can use

Divided into the upper and lower columns, the above code, run the results below, very convenient

Set Key binding

Every time this goes to the menu bar to find, too slow, can be like ctrl+b directly run it?

Yes, just set the shortcut key, in Preference->key Bindings-user.

Write the following configuration:

[

{"Keys": ["F4"],

"caption": "Sublimerepl:python-run current File",

"Command": "Run_existing_window_command", "args":

{

"id": "repl_python_run",

"File": "Config/python/main.sublime-menu"

}

},

{"Keys": ["F5"],

"caption": "Sublimerepl:python3.5-run current File",

"Command": "Run_existing_window_command", "args":

{

"id": "repl_python3.5_run",

"File": "Config/python3.5/main.sublime-menu"

}

}

]

Note the ID or the ID in the Menu.sublime-menu file to be consistent, F4 run 2.7 repl F5 run 3.5 repl

F4 works correctly, but F5 throws an exception, and when there is no response or error, you can look at the console

Valueerror:no JSON Object could be decoded

This shows that our python3.5 Menu.sublime-menu file has a problem,

Using the JSON online grammar checker

http://jsonlint.com/

It says it's Menu.sublime-menu's notes//Run files are not legal, and after removing the comments, the F5 will work as well.

The following problems occur when you run multiple times

Can ' t open file ' $file _basename ': [Errno 2] No such file or directory

Just once again with the mouse click on the test.py is good, you can get the running files

JSON syntax and annotations

In fact, a JSON file is simply a format for recording data, not as a configuration file like XML.

Comments were removed from JSON by design.

I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would has Destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn ' t.

Suppose you is using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments. Then pipe it through jsmin before handing it to your JSON parser.

Source: Public Statement by Douglas Crockford on g+

The reason why sublime can support annotated JSON, perhaps it was parsed before committing, but our exception from Python3.3 Note that python3.3 does not support parsing this annotated JSON, so you should not add the annotated JSON later

JSON (JavaScript Object Notation) is a simple data format that is lighter than XML. JSON is a lightweight data interchange format that is ideal for server-to-JavaScript interaction. JSON is a native JavaScript format, which means that working with JSON data in JavaScript does not require any special APIs or toolkits. It is easy to read and write, but also easy for machine parsing and generation. It is based on a subset of JavaScript (standard ECMA-262 3rd edition-december 1999). JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl, Python, etc.). These features make JSON an ideal data exchange language.

II. Coding Rules for JSON

The rules of JSON are simple: an object is an unordered collection of "name/value pairs". An object starts with "{" (opening parenthesis) and "}" (the closing parenthesis) ends. Each "name" is followed by a ":" (colon); "' Name/value ' pair ' is separated by", "(comma).

The rules are as follows:

1. The map is represented by a colon (":"). Name: Value

2. The parallel data is separated by commas (","). Name 1: value 1, Name 2: Value 2

3. The mapped collection (object) is represented by braces ("{}").

{

Name 1: value 1,

Name 2: Value 2

}

4. A set of side data (arrays) is expressed in square brackets ("[]").

[

{Name 1: value, Name 2: Value 2},

{Name 1: value, Name 2: Value 2}

]

Create object objects: Always end with {start with}, each property name of an object is separated from the property value in English with the default colon (:), and multiple properties are separated in English (,): The syntax format is as follows:

Student = {

Name: "Kouxiaolin",

Age:22,

Sex: "Female"

}

Note: When you create an object using JSON syntax, the property is not just a normal character, it can be any basic data type, it can be a function, an array, or even another object created in JSON syntax.

Teacher = {

Name: "Xiaoqian",

student:{

Name: "Kouxiaolin",

Sex: "Female"

},

Assigning a method to a teacher object using JSON

Tostring:function () {

Alert ("Test of Method ....");

}

}

JSON creates an array with the brackets [start and then end in brackets] in English. The element in which the array is placed. The elements are separated by commas in English, and the last comma is not required.

For example:

ARR = [Value1,value2,value3,.........]

JSON uses JavaScript syntax

because JSON Use JavaScript syntax, so no additional software is needed to handle JavaScript in the JSON .

through JavaScript , you can create an array of objects and assign values like this:

Example

var employees = [

{"FirstName": "Bill", "LastName": "Gates"},

{"FirstName": "George", "LastName": "Bush"},

{"FirstName": "Thomas", "LastName": "Carter"}

];

can be accessed like this JavaScript the first item in an array of objects:

Employees[0].lastname;

The returned content is:

Gates

You can modify the data like this:

Employees[0].lastname = "Jobs";

Cities =[

province1:{

Name: "Beijing",

city[

"Daxing", "Changping", "Chaoyang", "Haidian", "Dongcheng", "Xicheng"

]

},

Province2: {

Name: "Henan",

city[

"Zhengzhou", "Anyang", "Pingdingshan", "Kaifeng", "Shangqiu", "Luoyang"

]

}

]

There are two objects in an array called cities, Province1 Province2:

Province1 has a name and city two attributes, of which the city attribute is a number of groups, inside there are "daxing", "Changping", "Chaoyang", "Haidian", "Dongcheng", "Xicheng These values

SUBLIMEREPL Configuration Python3 Development

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.