background preloader

Learning to program

Learning to program

The Node Beginner Book » A comprehensive Node.js tutorial Text Processing in Python (a book) A couple of you make donations each month (out of about a thousand of you reading the text each week). Tragedy of the commons and all that... but if some more of you would donate a few bucks, that would be great support of the author. In a community spirit (and with permission of my publisher), I am making my book available to the Python community. Minor corrections can be made to later printings, and at the least errata noted on this website. Email me at <mertz@gnosis.cx> . A few caveats: (1) This stuff is copyrighted by AW (except the code samples which are released to the public domain).

Understanding JavaScript Closures In JavaScript, a closure is a function to which the variables of the surrounding context are bound by reference. Every JavaScript function forms a closure on creation. In a moment I’ll explain why and walk through the process by which closures are created. Then I’ll address some common misconceptions and finish with some practical applications. But first a brief word from our sponsors: JavaScript closures are brought to you by lexical scope and the VariableEnvironment… Lexical Scope The word lexical pertains to words or language. Consider the following example: Function inner is physically surrounded by function outer which in turn is wrapped by the global context. global outer inner The outer lexical scope of any given function is defined by its ancestors in the lexical hierarchy. VariableEnvironment The global object has an associated execution context. We could represent the VariableEnvironment with pseudo-code… However, it turns out this is only part of the picture. The [[scope]] property

Python Constraints HomeContents In this part of the SQLite tutorial, we will work with constraints. Constraints are placed on columns. They limit the data, that can be inserted into tables. We have the following constraints: NOT NULL constraint A column with a NOT NULL constraint cannot have NULL values. sqlite> CREATE TABLE People(Id INTEGER, LastName TEXT NOT NULL, ...> FirstName TEXT NOT NULL, City TEXT); We create two columns with NOT NULL constraints. sqlite> INSERT INTO People VALUES(1, 'Hanks', 'Robert', 'New York'); sqlite> INSERT INTO People VALUES(2, NULL, 'Marianne', 'Chicago'); Error: People.LastName may not be NULL The first INSERT statement succeeds, while the second fails. UNIQUE constraint The UNIQUE constraint ensures that all data are unique in a column. sqlite> CREATE TABLE Brands(Id INTEGER, BrandName TEXT UNIQUE); Here we create a table Brands. We get an error 'column BrandName is not unique'. Note that a PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it. Primary key

Python re Module - Use Regular Expressions with Python - Regex Support Python is a high level open source scripting language. Python's built-in "re" module provides excellent support for regular expressions, with a modern and complete regex flavor. The only significant features missing from Python's regex syntax are atomic grouping, possessive quantifiers, and Unicode properties. The first thing to do is to import the regexp module into your script with import re. Regex Search and Match Call re.search(regex, subject) to apply a regex pattern to a subject string. You can set regex matching modes by specifying a special constant as a third parameter to re.search(). re.I or re.IGNORECASE applies the pattern case insensitively. re.S or re.DOTALL makes the dot match newlines. re.M or re.MULTILINE makes the caret and dollar match after and before line breaks in the subject string. By default, Python's regex engine only considers the letters A through Z, the digits 0 through 9, and the underscore as "word characters". Do not confuse re.search() with re.match().

PyQT Tutorial Tutorial: Creating GUI Applications in Python with QTby Alex Fedosov Python is a great language with many awesome features, but its default GUI package (TkInter) is rather ugly. Besides, who wants to write all that GUI code by hand, anyway? Instead, a much better way to write GUI apps in Python is to use Trolltech's QT Designer to WYSIWYG-ly create a nice-looking interface, and then automatically generate the necessary code for it with pyuic (which is a UI compiler for QT that comes with the PyQT package.) QT designer also makes it very easy to add Python code to your project. (If you want your app to do anything useful, you will undoubtedly need to write some code. :) ) So the following is a brief tutorial on how to go about creating your first semi-interesting application with Python & QT. First, you need to have the following packages installed: Python 2.x PyQt 3.x QT Designer 3.x I did everything with default packages that came with Fedora Core 1, and had no problems.

Python Programming - Free computer books Python is an object-oriented high-level programming language created by Guido van Rossum in 1990. Python has a fully dynamic type system and uses automatic memory management; it is thus similar to Perl, Ruby, Scheme, Smalltalk, and Tcl. The philosophy behind Python is noteworthy among high-level programming languages because it emphasizes the importance of programmer effort over computer effort, and because it rejects more arcane language features, prioritizing readability over speed or expressiveness. Miscellaneous parts of the language have formal specifications and standards, but not the language as a whole.

Related: