Tutorial by Examples: di

import json s = '{"wonderland": [1, 2, 3], "foo": "bar", "alice": 1}' json.loads(s) The above snippet will return the following: {u'alice': 1, u'foo': u'bar', u'wonderland': [1, 2, 3]}
git diff This will show the unstaged changes on the current branch from the commit before it. It will only show changes relative to the index, meaning it shows what you could add to the next commit, but haven't. To add (stage) these changes, you can use git add. If a file is staged, but was modi...
git diff --staged This will show the changes between the previous commit and the currently staged files. NOTE: You can also use the following commands to accomplish the same thing: git diff --cached Which is just a synonym for --staged or git status -v Which will trigger the verbose sett...
Overview Checkboxes and radio buttons are written with the HTML tag <input>, and their behavior is defined in the HTML specification. The simplest checkbox or radio button is an <input> element with a type attribute of checkbox or radio, respectively: <input type="checkbox&quo...
It is possible to send a value to the generator by passing it to the next() method. function* summer() { let sum = 0, value; while (true) { // receive sent value value = yield; if (value === null) break; // aggregate values sum += value; ...
There are multiple ways to append values onto an array var exampleArray = [1,2,3,4,5] exampleArray.append(6) //exampleArray = [1, 2, 3, 4, 5, 6] var sixOnwards = [7,8,9,10] exampleArray += sixOnwards //exampleArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and remove values from an array exampleAr...
The basic syntax of SELECT with WHERE clause is: SELECT column1, column2, columnN FROM table_name WHERE [condition] The [condition] can be any SQL expression, specified using comparison or logical operators like >, <, =, <>, >=, <=, LIKE, NOT, IN, BETWEEN etc. The following ...
SELECT PhoneNumber, Email, PreferredContact FROM Customers This statement will return the columns PhoneNumber, Email, and PreferredContact from all rows of the Customers table. Also the columns will be returned in the sequence in which they appear in the SELECT clause. The re...
In addition to receiving values from a generator, it is possible to send an object to a generator using the send() method. def accumulator(): total = 0 value = None while True: # receive sent value value = yield total if value is None: break # aggr...
a, b = 1, 2 # Using the "+" operator: a + b # = 3 # Using the "in-place" "+=" operator to add and assign: a += b # a = 3 (equivalent to a = a + b) import operator # contains 2 argument arithmetic functions for the examp...
Python does integer division when both operands are integers. The behavior of Python's division operators have changed from Python 2.x and 3.x (see also Integer Division ). a, b, c, d, e = 3, 2, 2.0, -3, 10 Python 2.x2.7 In Python 2 the result of the ' / ' operator depends on the type of the nu...
Rounding Math.round() will round the value to the closest integer using half round up to break ties. var a = Math.round(2.3); // a is now 2 var b = Math.round(2.7); // b is now 3 var c = Math.round(2.5); // c is now 3 But var c = Math.round(-2.7); // c is now -3 va...
You can include another Git repository as a folder within your project, tracked by Git: $ git submodule add https://github.com/jquery/jquery.git You should add and commit the new .gitmodules file; this tells Git what submodules should be cloned when git submodule update is run.
Dictionaries are an unordered collection of keys and values. Values relate to unique keys and must be of the same type. When initializing a Dictionary the full syntax is as follows: var books : Dictionary<Int, String> = Dictionary<Int, String>() Although a more concise way of initia...
Add a key and value to a Dictionary var books = [Int: String]() //books = [:] books[5] = "Book 5" //books = [5: "Book 5"] books.updateValue("Book 6", forKey: 5) //[5: "Book 6"] updateValue returns the original value if one exists or nil. let previous...
This example uses the Cars Table from the Example Databases. UPDATE Cars SET TotalCost = TotalCost + 100 WHERE Id = 3 or Id = 4 Update operations can include current values in the updated row. In this simple example the TotalCost is incremented by 100 for two rows: The TotalCost of Car #3 i...
The general syntax for declaring a one-dimensional array is type arrName[size]; where type could be any built-in type or user-defined types such as structures, arrName is a user-defined identifier, and size is an integer constant. Declaring an array (an array of 10 int variables in this case) i...
Git will usually open an editor (like vim or emacs) when you run git commit. Pass the -m option to specify a message from the command line: git commit -m "Commit message here" Your commit message can go over multiple lines: git commit -m "Commit 'subject line' message here Mor...
For example calculating the average of each i-th element of multiple iterables: def average(*args): return float(sum(args)) / len(args) # cast to float - only mandatory for python 2.x measurement1 = [100, 111, 99, 97] measurement2 = [102, 117, 91, 102] measurement3 = [104, 102, 95, 101] ...
[0-9] and \d are equivalent patterns (unless your Regex engine is unicode-aware and \d also matches things like ②). They will both match a single digit character so you can use whichever notation you find more readable. Create a string of the pattern you wish to match. If using the \d notation, you...

Page 6 of 164