Tutorial by Examples: c

Classes have a local scope during definition, but functions inside the class do not use that scope when looking up names. Because lambdas are functions, and comprehensions are implemented using function scope, this can lead to some surprising behavior. a = 'global' class Fred: a = 'class' ...
$> pwd /home/myUserHome $> cd .. $> pwd /home will print the current path to the console.
Basic assembly support with gcc has the following syntax: asm [ volatile ] ( AssemblerInstructions ) where AssemblerInstructions is the direct assembly code for the given processor. The volatile keyword is optional and has no effect as gcc does not optimize code within a basic asm statement. A...
Extended asm support in gcc has the following syntax: asm [volatile] ( AssemblerTemplate : OutputOperands [ : InputOperands [ : Clobbers ] ]) asm [volatile] goto ( AssemblerTemplate : : Inp...
This attribute is used to describe the product that this particular assembly is for. Multiple assemblies can be components of the same product, in which case they can all share the same value for this attribute. [assembly: AssemblyProduct("MyProduct")]
File static class By using Create method of the File static class we can create files. Method creates the file at the given path, at the same time it opens the file and gives us the FileStream of the file. Make sure you close the file after you are done with it. ex1: var fileStream1 = File.Create...
File static class File static class can be easily used for this purpose. File.Copy(@"sourcePath\abc.txt", @"destinationPath\abc.txt"); File.Copy(@"sourcePath\abc.txt", @"destinationPath\xyz.txt"); Remark: By this method, file is copied, meaning that it w...
Jupyter Notebooks are an interactive, browser-based development environment. They were originally developed to run computation python and as such play very well with numpy. To try numpy in a Jupyter notebook without fully installing either on one's local system Rackspace provides free temporary note...
Well, if you want a switch/case construct, the most straightforward way to go is to use the good old if/else construct: def switch(value): if value == 1: return "one" if value == 2: return "two" if value == 42: return "the answer to...
Another straightforward way to go is to create a dictionary of functions: switch = { 1: lambda: 'one', 2: lambda: 'two', 42: lambda: 'the answer of life the universe and everything', } then you add a default function: def default_case(): raise Exception('No case found!') ...
You can use a class to mimic the switch/case structure. The following is using introspection of a class (using the getattr() function that resolves a string into a bound method on an instance) to resolve the "case" part. Then that introspecting method is aliased to the __call__ method to ...
Another way, which is very readable and elegant, but far less efficient than a if/else structure, is to build a class such as follows, that will read and store the value to compare with, expose itself within the context as a callable that will return true if it matches the stored value: class Switc...
SQL has various join types to specify whether (non-)matching rows are included in the result: INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN (the INNER and OUTER keywords are optional). The figure below underlines the differences between these types of joins: the blue area repres...
It might be easier if you think of GROUP BY as "for each" for the sake of explanation. The query below: SELECT EmpID, SUM (MonthlySalary) FROM Employee GROUP BY EmpID is saying: "Give me the sum of MonthlySalary's for each EmpID" So if your table looked like this: +----...
I created custom label with wrapper around FormattedText property: public class MultiComponentLabel : Label { public IList<TextComponent> Components { get; set; } public MultiComponentLabel() { var components = new ObservableCollection<TextComponent>(); ...
Pre-processing in caret is done through the preProcess() function. Given a matrix or data frame type object x, preProcess() applies transformations on the training data which can then be applied to testing data. The heart of the preProcess() function is the method argument. Method operations are ap...
It is possible to perform ViewActions on a view using the perform method. The ViewActions class provides helper methods for the most common actions, like: ViewActions.click() ViewActions.typeText() ViewActions.clearText() For example, to click on the view: onView(...).perform(click()); onVi...
If you do row-by-row processing in Salesforce, you'll probably reach the governor limit quickly. This is especially true with triggers and things that fire when you don't expect them. One documented method of escaping the governor limit is bulkification. Note: The following information is based on ...
Classes are vital aspects of OOP. A class is like the "blueprint" of an object. An object has the properties of a class, but the characteristics are not defined within the class itself. As each object can be different, they define their own characteristics. Public Class Person End Class ...
Inherits Specifies the base (or parent) class Public Class Person End Class Public Class Customer Inherits Person End Class 'One line notation Public Class Student : Inherits Person End Class Possible objects: Dim p As New Person Dim c As New Customer Dim s As New Student ...

Page 358 of 826