Tutorial by Examples: an

Import the ElementTree object, open the relevant .xml file and get the root tag: import xml.etree.ElementTree as ET tree = ET.parse("yourXMLfile.xml") root = tree.getroot() There are a few ways to search through the tree. First is by iteration: for child in root: print(child.ta...
(Note: All examples using let are also valid for const) var is available in all versions of JavaScript, while let and const are part of ECMAScript 6 and only available in some newer browsers. var is scoped to the containing function or the global space, depending when it is declared: var x = 4; /...
Final classes When used in a class declaration, the final modifier prevents other classes from being declared that extend the class. A final class is a "leaf" class in the inheritance class hierarchy. // This declares a final class final class MyFinalClass { /* some code */ } ...
The and-operator (&&) and the or-operator (||) employ short-circuiting to prevent unnecessary work if the outcome of the operation does not change with the extra work. In x && y, y will not be evaluated if x evaluates to false, because the whole expression is guaranteed to be false....
# Set the repository for the scope "myscope" npm config set @myscope:registry http://registry.corporation.com # Login at a repository and associate it with the scope "myscope" npm adduser --registry=http://registry.corporation.com --scope=@myscope # Install a package &quo...
The $_SESSION variable is an array, and you can retrieve or manipulate it like a normal array. <?php // Starting the session session_start(); // Storing the value in session $_SESSION['id'] = 342; // conditional usage of session values that may have been set in a previous session if(!i...
project/jni/main.c #include <stdio.h> #include <unistd.h> int main(void) { printf("Hello world!\n"); return 0; } project/jni/Android.mk LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello_world LOCAL_SRC_FILES := main.c include $(BU...
Given that the module from the Defining a Module section exists in the file test.js, you can import from that module and use its exported members: import {doSomething, MyClass, PI} from './test' doSomething() const mine = new MyClass() mine.test() console.log(PI) The somethingPrivate()...
In addition to importing named members from a module or a module's default export, you can also import all members into a namespace binding. import * as test from './test' test.doSomething() All exported members are now available on the test variable. Non-exported members are not available, j...
To create a new branch, while staying on the current branch, use: git branch <name> Generally, the branch name must not contain spaces and is subject to other specifications listed here. To switch to an existing branch : git checkout <name> To create a new branch and switch to it...
$ git branch -d dev Deletes the branch named dev if its changes are merged with another branch and will not be lost. If the dev branch does contain changes that have not yet been merged that would be lost, git branch -d will fail: $ git branch -d dev error: The branch 'dev' is not fully merged...
The term "IFrame" means Inline Frame. It can be used to include another page in your page. This will yield a small frame which shows the exact contents of the base.html. <iframe src="base.html"></iframe>
Normally a change of webpage within an Iframe is initiated from with the Iframe, for example, clicking a link inside the Ifame. However, it is possible to change an IFrame's content from outside the IFrame. You can use an anchor tag whose href attribute is set to the desired URL and whose target at...
jQuery code is often wrapped in jQuery(function($) { ... }); so that it only runs after the DOM has finished loading. <script type="text/javascript"> jQuery(function($) { // this will set the div's text to "Hello". $("#myDiv").text("Hello"...
These are all equivalent, the code inside the blocks will run when the document is ready: $(function() { // code }); $().ready(function() { // code }); $(document).ready(function() { // code }); Because these are equivalent the first is the recommended form, the following is a ...
To remove an element inside an array, e.g. the element with the index 1. $fruit = array("bananas", "apples", "peaches"); unset($fruit[1]); This will remove the apples from the list, but notice that unset does not change the indexes of the remaining elements. So $fr...
Boolean is a type, having two values, denoted as true or false. This code sets the value of $foo as true and $bar as false: $foo = true; $bar = false; true and false are not case sensitive, so TRUE and FALSE can be used as well, even FaLsE is possible. Using lower case is most common and recom...
var='0123456789abcdef' # Define a zero-based offset $ printf '%s\n' "${var:3}" 3456789abcdef # Offset and length of substring $ printf '%s\n' "${var:3:4}" 3456 4.2 # Negative length counts from the end of the string $ printf '%s\n' "${var:3:-5}" 3456789a...
cat < file.txt Output is same as cat file.txt, but it reads the contents of the file from standard input instead of directly from the file. printf "first line\nSecond line\n" | cat -n The echo command before | outputs two lines. The cat command acts on the output to add line num...
Classes/structs can have inheritance relations. If a class/struct B inherits from a class/struct A, this means that B has as a parent A. We say that B is a derived class/struct from A, and A is the base class/struct. struct A { public: int p1; protected: int p2; private: int p3;...

Page 16 of 307