From 4a735f833653551e3321fbe9a8e47faa879d282f Mon Sep 17 00:00:00 2001
From: kinitrupti
Date: Thu, 15 Oct 2015 17:40:30 +0530
Subject: solved errors
---
.../.ipynb_checkpoints/ch1-checkpoint.ipynb | 261 +++++++++
.../.ipynb_checkpoints/ch10-checkpoint.ipynb | 490 +++++++++++++++++
.../.ipynb_checkpoints/ch12-checkpoint.ipynb | 355 ++++++++++++
.../.ipynb_checkpoints/ch13-checkpoint.ipynb | 350 ++++++++++++
.../.ipynb_checkpoints/ch15-checkpoint.ipynb | 611 +++++++++++++++++++++
.../.ipynb_checkpoints/ch2-checkpoint.ipynb | 249 +++++++++
.../ch1.ipynb | 39 +-
.../ch10.ipynb | 67 +--
.../ch12.ipynb | 22 +-
.../ch13.ipynb | 18 +-
.../ch15.ipynb | 38 +-
.../ch2.ipynb | 19 +-
12 files changed, 2386 insertions(+), 133 deletions(-)
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch1-checkpoint.ipynb
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch10-checkpoint.ipynb
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch12-checkpoint.ipynb
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch13-checkpoint.ipynb
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch15-checkpoint.ipynb
create mode 100755 C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch2-checkpoint.ipynb
(limited to 'C++_in_Action_-_Industrial-Strength_Programming_Techniques')
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch1-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch1-checkpoint.ipynb
new file mode 100755
index 00000000..a9c91080
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch1-checkpoint.ipynb
@@ -0,0 +1,261 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:2af50dca95bb8940069ca1eefad39c58f8f97bbf13a194cd9fff16b4f6521b4f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter One : Naming"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.1 Page no : 2 \n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "strL = 0 # Not recommended\n",
+ "stringLength = 0 # Recommended"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 2 Page no : 3\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcFruit:\n",
+ " def print_(self):\n",
+ " pass\n",
+ "\n",
+ "class EmcApple(EmcFruit):\n",
+ " def print_(self):\n",
+ " pass\n",
+ "\n",
+ "fp = EmcApple()\n",
+ "print fp "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "<__main__.EmcApple instance at 0x9d29c8c>\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.3 Page no : 4\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "class Point:\n",
+ " def __init__(self,a,b):\n",
+ " self.x = a\n",
+ " self.y = b\n",
+ " def x1(self,a):\n",
+ " self.x = a\n",
+ "\n",
+ "p = Point(0,0) # a point in a 2-dimensional space\n",
+ "p.x1(1); # set X-coordinate\n",
+ "print p.x # prints X-coordinate, \"1\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.4 page no : 4\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "def check_assign(a,i,t):\n",
+ " if (i < len(a)):\n",
+ " a[i] = t;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.5 Page no : 6\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "class String:\n",
+ " pass\n",
+ "\n",
+ "class DynamicArray:\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.6 page no : 6\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "a = 'aaa' \n",
+ "s1 = 'xyz'\n",
+ "s = 'abc' # Emc::String s;\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.8 page no : 7\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#s1 = EmcString() # Belongs to the Emc Class Library\n",
+ "#s2 = OtherString() # Belongs to the Other Class Library"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.9 Page no : 8\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#import RWCstring #include \"RWCstring.h\" /* Recommended */\n",
+ "#from rw import cstring #include \"rw/cstring.h\" /* Sometimes needed */"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 1.10 page no : 9\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "i__j = 11;\n",
+ "_K = 22;\n",
+ "_m = 33;\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch10-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch10-checkpoint.ipynb
new file mode 100755
index 00000000..6292c70e
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch10-checkpoint.ipynb
@@ -0,0 +1,490 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:70f9ab632bffbd9fecc3bdcee575cac266cb09d4df74fddec4e595d028f134df"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
Chapter Ten : Object-oriented programming
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Example 10.1 page no :105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "s = \"hello\" # length() == 5\n",
+ "print s\n",
+ "print len(s)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "hello\n",
+ "5"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.2 page no : 106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "s = \"Hello\"\n",
+ "\n",
+ "s = s.lower()\n",
+ "print s"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "hello"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ " example 10.3 page no :107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcCollection:\n",
+ " \n",
+ " def insert(self,t):\n",
+ " pass\n",
+ " \n",
+ " def operator(self, coll):\n",
+ " pass\n",
+ "\n",
+ "class EmcArrayCollection(EmcCollection):\n",
+ " initialSize = 10\n",
+ "\n",
+ " def __init__(self,maxsize):\n",
+ " pass\n",
+ "\n",
+ "\"\"\"\n",
+ "class InvalidCollectionType(EmcException):\n",
+ " \n",
+ " def __init__(self,i):\n",
+ " pass\n",
+ " \"\"\"\n",
+ "\n",
+ "class EmcCollectionFactory:\n",
+ " def __init__(self):\n",
+ " pass\n",
+ "\n",
+ " def create(self,type):\n",
+ " pass\n",
+ "\n",
+ " def createArray(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "example 10.4 page no :109"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class EmcCollectionFactory:\n",
+ " def __init__(self):\n",
+ " pass\n",
+ "\n",
+ " def create(self,type):\n",
+ " pass\n",
+ "\n",
+ " def createArray(self):\n",
+ " pass\n",
+ "\n",
+ "factory = EmcCollectionFactory()\n",
+ "collection = factory.create(\"Array\")\n",
+ "collection.insert(42); # EmcArrayCollection::insert() is called\n",
+ "print collection"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "None\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "example 10.5 page no : 111"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcCollection:\n",
+ " def __del__(self):\n",
+ " pass\n",
+ "\n",
+ "class EmcArrayCollection( EmcCollection):\n",
+ " def __del__(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "example 10.6 page no :112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcLogged:\n",
+ " def writeClassName(self,o):\n",
+ " pass\n",
+ "\n",
+ " def writeValue(self,o):\n",
+ " pass\n",
+ "\n",
+ " def logMessage(self,message):\n",
+ " pass\n",
+ "\n",
+ " def __del__(self):\n",
+ " pass\n",
+ "\n",
+ "class EmcLoggedCollection(EmcCollection):\n",
+ "\n",
+ " def writeValue(self,o):\n",
+ " pass\n",
+ "\n",
+ " def __del__(self):\n",
+ " pass "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.7 Page no : 117"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "\n",
+ "class EmcIntStack:\n",
+ " def empty(self):\n",
+ " pass\n",
+ "\n",
+ " def full(self):\n",
+ " pass\n",
+ " \n",
+ " def top(self):\n",
+ " pass\n",
+ " \n",
+ " def push(self,i):\n",
+ " pass\n",
+ " \n",
+ " def pop(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.8 Page no : 117"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def makeString(stack):\n",
+ " returnValue = ''\n",
+ " copy = stack\n",
+ " while (not copy.empty()):\n",
+ " # loop condition makes precondition valid\n",
+ " print copy.pop() # Precondition: ! copy.empty()\n",
+ " returnValue += copy.pop\n",
+ "\n",
+ " return returnValue;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.9 page no : 118"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcString:\n",
+ " def cStr(self):\n",
+ " pass\n",
+ " # cStr() returns 0-terminated string\n",
+ "\n",
+ " def length(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.10 page no : 119"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcCollection:\n",
+ " def __del__(self):\n",
+ " pass\n",
+ "\n",
+ " def insert(self,T):\n",
+ " pass\n",
+ "\n",
+ " def clear(self):\n",
+ " pass\n",
+ "\n",
+ " def remove(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.11 page no : 120"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "class EmcCollectionFactory:\n",
+ " def __init__(self):\n",
+ " pass\n",
+ "\n",
+ " def create(self,type):\n",
+ " pass\n",
+ "\n",
+ " def createArray(self):\n",
+ " pass\n",
+ " \n",
+ "factrory = EmcCollectionFactory()\n",
+ "collection = factory.create(\"Array\");\n",
+ "if (not collection.isFull()):\n",
+ " collection.insert(42);"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.12 page no : 121"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "def insertObject(c,element):\n",
+ " \n",
+ " if (not c.isFull()):\n",
+ " c.insert(element)\n",
+ " return True\n",
+ " return False"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.13 Page no : 121"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "def insert(T):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.14 page no : 123"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcCollection:\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 10.15 page no : 124"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcCollection:\n",
+ " def templateRequirements(self):\n",
+ " pass\n",
+ "\n",
+ " def templateRequirements(self):\n",
+ " \n",
+ " t1 = T1()\n",
+ " \n",
+ " t2 =t1\n",
+ "\n",
+ " t2 = t1;\n",
+ " # Assignable\n",
+ " b = (t2 == t1); # EqualityComparable"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch12-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch12-checkpoint.ipynb
new file mode 100755
index 00000000..c8f2cfb1
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch12-checkpoint.ipynb
@@ -0,0 +1,355 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3fda869111a137bc83ae4b79f3c57ac84f247031c3e08ac7d6dfb9bb168b3105"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Chapter Twelve : Error handling"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.1 page no : 135"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import socket\n",
+ "import sys\n",
+ "import os\n",
+ "sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM,0)\n",
+ "\n",
+ "if(sock < 0):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.2 page no : 136"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcException:\n",
+ " def operator(self,n):\n",
+ " pass\n",
+ "\n",
+ "class EmcSystemException( EmcException):\n",
+ " def __init__(self,m):\n",
+ " pass\n",
+ " \n",
+ " def emcSocket(self,family,t,protocol):\n",
+ " # create socket\n",
+ " socketfd = socket(family, t, protocol);\n",
+ " if (socketfd < 0): # check status value\n",
+ " raise EmcSystemException(\"emcSocket\");\n",
+ " return socketfd;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.3 page no : 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def __init__(self,cp):\n",
+ " self.lengthM = len(cp)\n",
+ " self.cpM = cp"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.5 page no : 141"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcLog:\n",
+ " def __init__(self,filename):\n",
+ " pass\n",
+ "\n",
+ " def message(self,EmcString):\n",
+ " pass\n",
+ "\n",
+ " def __del__(self):\n",
+ " if uncaught_exception():\n",
+ " self.flush()\n",
+ " \n",
+ " def flush(self):\n",
+ " if ( not uncaught_exception()):\n",
+ " raise EmcSystemException(\"EmcLog::flush()\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.6 page no : 142"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcException:\n",
+ " def __init__(self,m):\n",
+ " maxSizeM = 100\n",
+ " actualLength = len(m);\n",
+ " self.lengthM = min(maxSizeM,actualLength);\n",
+ " self.messageM = message"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def f():\n",
+ " ip = 1\n",
+ " g(ip)\n",
+ "\n",
+ "\n",
+ "def g(i):\n",
+ " raise Exception(i)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.8 page no : 146"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def f():\n",
+ " ip = 1\n",
+ " g(ip)\n",
+ "\n",
+ "def g(i):\n",
+ " raise Exception(i)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.9 page no :146"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "def f():\n",
+ " ip = 1\n",
+ " g(ip)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.10 page no : 148"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcStack:\n",
+ " defaultSizeM = 100\n",
+ " def __init__(self,size = 100):\n",
+ " pass\n",
+ "\n",
+ " def __del__(self):\n",
+ " pass\n",
+ "\n",
+ " def operator(self,s):\n",
+ " pass\n",
+ "\n",
+ " def empty(self):\n",
+ " pass\n",
+ " \n",
+ " def top(self):\n",
+ " pass\n",
+ "\n",
+ " def push(self,i):\n",
+ " pass\n",
+ " \n",
+ " def pop(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.12 page no : 151"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcException:\n",
+ " def __init__(self,m):\n",
+ " pass\n",
+ " \n",
+ " def operator(self,o,EmcException):\n",
+ " pass\n",
+ "\n",
+ " def printOn(self,o): \n",
+ " print self.messageM;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.13 page no : 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "try:\n",
+ " socketfd = emcSocket(AF_UNIX, SOCK_STREAM, 0);\n",
+ "except Exception,e:\n",
+ " print e"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 'emcSocket' is not defined"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 12.14 page no : 155"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def at(s,pos):\n",
+ " if (pos > len(s)):\n",
+ " raise Exception;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch13-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch13-checkpoint.ipynb
new file mode 100755
index 00000000..8bf2f3f0
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch13-checkpoint.ipynb
@@ -0,0 +1,350 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:121cbe714f8e854e8d9ce1fe8dcdc370535cc7140b2f83bdae09063602e644f9"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ " Chapter Thirteen : Parts of C++ to avoid"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.1 page no : 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "s = 'abc' #raw_input()\n",
+ "print s"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "abc"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.2 page no : 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "class DangerousString:\n",
+ " def __init__(self,cp):\n",
+ " pass\n",
+ " \n",
+ " def char(self):\n",
+ " pass\n",
+ "\n",
+ "hello = \"Hello World!\";\n",
+ "print hello # Works perfectly\n",
+ "print \"%s\"%hello"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hello World!\n",
+ "Hello World!"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.3 page no : 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "class EmcString:\n",
+ " def __init__(self,cp):\n",
+ " pass\n",
+ "\n",
+ "\n",
+ "s = \"Hello World!\";\n",
+ "print s "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hello World!"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.4 page no :161"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "SIZE = 1024;\n",
+ "print SIZE"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1024"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.5 page no : 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class X:\n",
+ " class Color:\n",
+ " green = 1\n",
+ " yellow = 2\n",
+ " red = 3"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.6 page no : 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class X:\n",
+ " maxBuf = 1024\n",
+ " class Color:\n",
+ " green = 1\n",
+ " yellow = 2\n",
+ " red = 3"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.7 page no : 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "def SQUARE(x):\n",
+ " return x*x\n",
+ "\n",
+ "i = SQUARE(3 + 4); \n",
+ "print i"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "49"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.8 page no : 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "def square(x):\n",
+ " return x * x;\n",
+ "c = 2;\n",
+ "d = square(c)\n",
+ "print d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.9 page no : 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\"\"\"\n",
+ "def SQUARE(x):\n",
+ " return x*x\n",
+ "i = SQUARE(\"hello\");\n",
+ "print i\n",
+ "\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 10,
+ "text": [
+ "'\\ndef SQUARE(x):\\n return x*x\\ni = SQUARE(\"hello\");\\nprint i\\n'"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.10 page no : 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#define Velocity int\n",
+ "#typedef int Velocity;\n",
+ "# Not recommended"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 11,
+ "text": [
+ "'\\nEXAMPLE 13.10 page no : 163\\nHow to define synonyms for a type\\nNote : Python doesnot have synonyms for type as we do not have to explicitely \\ndeclare variables.\\n'"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 13.11 page no : 164"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def printFruits(fruits,size):\n",
+ " for i in range(size):\n",
+ " print fruits[i] "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch15-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch15-checkpoint.ipynb
new file mode 100755
index 00000000..62a8a475
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch15-checkpoint.ipynb
@@ -0,0 +1,611 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:24f5f3b754e3fd6e8afab7bcb99e41e817ec5bce9faae498ba9fb75dd53f93ff"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ " Chapter Fifteen : Portability"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.1 page no : 172"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "c = -100;\n",
+ "if (c < 0):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.2 page no : 173"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class BasicAttrType:\n",
+ " counterGauge = 0x1000\n",
+ " counterPeg = 0x2000\n",
+ " conterAcc = 0x3000\n",
+ " \n",
+ "\n",
+ "\n",
+ "t = BasicAttrType.counterGauge\n",
+ "print t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4096"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.3 page no : 173"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "a = ''\n",
+ "print a"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": []
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "example 15.5 page no : 174"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "result = 1234 * 567\n",
+ "print result"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "699678"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Example 15.6 page no : 175"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "import math # python has only one way to importing file.\n",
+ "from math import *"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "exmaple 15.7 page no : 176"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ " \n",
+ "# import inc.MyFile\n",
+ "# import inc.MyFile\n",
+ "\n",
+ "# import gui.xinterface"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 6,
+ "text": [
+ "'\\nexmaple 15.7 page no : 176\\nDirectory names in include directives\\nNote : python has . operator to import a file from directory\\n'"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.8 page no : 176"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "import math\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.9 page no : 178"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class PersonRecord:\n",
+ " ageM = ''\n",
+ " phoneNumberM = 0\n",
+ " nameM = ''"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.10 page no : 178"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "def stepAndConvert(a,n):\n",
+ " b = a + str(n) # step n chars ahead\n",
+ " return b # NO: Dangerous cast of const char* to int*\n",
+ "\n",
+ "\n",
+ "data = \"abcdefghijklmnop\"\n",
+ "anInt = 3;\n",
+ "i = stepAndConvert(data, anInt)\n",
+ "print i"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "abcdefghijklmnop3"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.11 page no : 179"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "INT_MIN = -2147483648\n",
+ "INT_MAX = 2147483647\n",
+ "UINT_MAX = 4294967295\n",
+ "i = 42\n",
+ "ui = 2222222242;\n",
+ "j = i - ui;\n",
+ "print j"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-2222222200"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.12 page no : 180"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "zero = 0;\n",
+ "one = 1;\n",
+ "minusOne = zero - one;\n",
+ "print minusOne\n",
+ "result = one + minusOne;\n",
+ "print result"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-1\n",
+ "0"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.13 page no : 180"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#pid1 = fork(); # NO: should use pid_t\n",
+ "\n",
+ "#pid2 = fork();"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.14 page no : 181"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "famousClimber = \"Edmund Hillary\"; # Uses Emc as prefix\n",
+ "print famousClimber"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Edmund Hillary"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.15 page no : 183"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcArray:\n",
+ " def __init__(self,size):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.16 page no : 183"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "\n",
+ "false = 0;\n",
+ "true = 1;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.17 page no : 184"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\"\"\"\n",
+ "i = 0;\n",
+ "for i in range(last()):\n",
+ " pass\n",
+ "\n",
+ "for i in range(first()):\n",
+ " pass\n",
+ " \"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 5,
+ "text": [
+ "'\\ni = 0;\\nfor i in range(last()):\\n pass\\n\\nfor i in range(first()):\\n pass\\n '"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.18 page no : 185"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "def emcMax(a, b):\n",
+ " if a>b:\n",
+ " return a\n",
+ " return b\n",
+ "\n",
+ "def foo(i,j):\n",
+ " m = emcMax(i, j); # usage of emcMax\n",
+ "\n",
+ "q = 0 # usage of class EmcQueue and\n",
+ "s = 0 # EmcQueue:s default constructor"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.19 page no : 186"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "class EmcQueue:\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.20 page no : 187"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "class DangerousString:\n",
+ " def __init__(self,cp):\n",
+ " pass\n",
+ "\n",
+ " def char(self):\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "example 15.22 page no : 189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "def main(self):\n",
+ " return 0"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.23"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "\n",
+ "\n",
+ "func(f1(), f2(), f3()) # f1 may be evaluated before f2 and f3,\n",
+ "# but don't depend on it!"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "EXAMPLE 15.24 page no : 189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "a = [0,0,0]\n",
+ "i = 0\n",
+ "a[i] = i;\n",
+ "i += 1\n",
+ "print i \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch2-checkpoint.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch2-checkpoint.ipynb
new file mode 100755
index 00000000..a2d1bd52
--- /dev/null
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/.ipynb_checkpoints/ch2-checkpoint.ipynb
@@ -0,0 +1,249 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:025b4c65298f5bb6d48b99d717b6d0fce940f5a97ad7eb75ea5897c4c9595891"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter : Two : Organizing the code"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.1 Page no : 12\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#import EmcArray # EmcArray.py\n",
+ "#import iostream # The rest of the EmcArray.cc file "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.2 page no : 13\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ " \n",
+ "\n",
+ "class X :\n",
+ " def __init__(self):\n",
+ " pass #self.aM = A()\n",
+ " \n",
+ " def returnA(self):\n",
+ " pass #return self.aM\n",
+ " \n",
+ " def withAParameter(self,a):\n",
+ " pass #self.aM = a"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.3 page no :14\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class Y :\n",
+ " def __init__(self):\n",
+ " pass #self.bM = B()\n",
+ " \n",
+ " def returnBPtr(self):\n",
+ " pass #return self.aM\n",
+ " \n",
+ " def withAParameter(self,b):\n",
+ " pass #self.bM = a\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.4 page no : 15\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "def module_exists(module_name):\n",
+ " try:\n",
+ " __import__(module_name)\n",
+ " except ImportError:\n",
+ " return False\n",
+ " else:\n",
+ " return True"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.5 page no : 15\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "def cStr(cpM):\n",
+ " return cpM\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.6 page no : 17\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "\n",
+ "def max_(x,y):\n",
+ " if x > y:\n",
+ " return x\n",
+ " return y\n",
+ "\n",
+ "def function(i,j):\n",
+ " m = max_(i,j) # must instantiate max(int,int)\n",
+ " print m\n",
+ "\n",
+ "function(5,10) \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.7 page no : 17\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcQueue:\n",
+ " def __init__(self):\n",
+ " pass\n",
+ " \n",
+ " def insert(self,t):\n",
+ " pass\n",
+ "\n",
+ "q = EmcQueue()\n",
+ "q.insert(42);"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "EXAMPLE 2.8 page no : 18\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "class EmcQueue:\n",
+ " pass"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb
index 834bacf2..a9c91080 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb
@@ -194,25 +194,13 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\n",
- "s1 = EmcString() # Belongs to the Emc Class Library\n",
- "s2 = OtherString() # Belongs to the Other Class Library"
+ "#s1 = EmcString() # Belongs to the Emc Class Library\n",
+ "#s2 = OtherString() # Belongs to the Other Class Library"
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "NameError",
- "evalue": "name 'EmcString' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mNote\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mthis\u001b[0m \u001b[0mwill\u001b[0m \u001b[0mgive\u001b[0m \u001b[0merror\u001b[0m \u001b[0mbecause\u001b[0m \u001b[0mfile\u001b[0m \u001b[0mdoesn\u001b[0m\u001b[0;31m'\u001b[0m\u001b[0mt\u001b[0m \u001b[0mhave\u001b[0m \u001b[1;32mclass\u001b[0m \u001b[0mEmcString\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mOtherString\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m '''\n\u001b[1;32m----> 6\u001b[1;33m \u001b[0ms1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mEmcString\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# Belongs to the Emc Class Library\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[0ms2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOtherString\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# Belongs to the Other Class Library\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mNameError\u001b[0m: name 'EmcString' is not defined"
- ]
- }
- ],
- "prompt_number": 7
+ "outputs": [],
+ "prompt_number": 4
},
{
"cell_type": "heading",
@@ -227,24 +215,13 @@
"collapsed": false,
"input": [
"\n",
- "import RWCstring #include \"RWCstring.h\" /* Recommended */\n",
- "from rw import cstring #include \"rw/cstring.h\" /* Sometimes needed */"
+ "#import RWCstring #include \"RWCstring.h\" /* Recommended */\n",
+ "#from rw import cstring #include \"rw/cstring.h\" /* Sometimes needed */"
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "ImportError",
- "evalue": "No module named RWCstring",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mNote\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mthis\u001b[0m \u001b[0mwould\u001b[0m \u001b[0mgive\u001b[0m \u001b[0merror\u001b[0m \u001b[0mbecause\u001b[0m \u001b[0mwe\u001b[0m \u001b[0mdont\u001b[0m \u001b[0mhave\u001b[0m \u001b[0mpackages\u001b[0m \u001b[0mwritten\u001b[0m \u001b[0mhere\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m '''\n\u001b[1;32m----> 7\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mRWCstring\u001b[0m \u001b[1;31m#include \"RWCstring.h\" /* Recommended */\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mrw\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mcstring\u001b[0m \u001b[1;31m#include \"rw/cstring.h\" /* Sometimes needed */\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mImportError\u001b[0m: No module named RWCstring"
- ]
- }
- ],
- "prompt_number": 8
+ "outputs": [],
+ "prompt_number": 5
},
{
"cell_type": "heading",
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb
index 52781089..6292c70e 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb
@@ -103,11 +103,12 @@
" def __init__(self,maxsize):\n",
" pass\n",
"\n",
- "\n",
+ "\"\"\"\n",
"class InvalidCollectionType(EmcException):\n",
" \n",
" def __init__(self,i):\n",
" pass\n",
+ " \"\"\"\n",
"\n",
"class EmcCollectionFactory:\n",
" def __init__(self):\n",
@@ -121,19 +122,8 @@
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "NameError",
- "evalue": "name 'EmcException' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 24\u001b[0;31m \u001b[0;32mclass\u001b[0m \u001b[0mInvalidCollectionType\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mEmcException\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'EmcException' is not defined"
- ]
- }
- ],
- "prompt_number": 3
+ "outputs": [],
+ "prompt_number": 2
},
{
"cell_type": "markdown",
@@ -146,10 +136,18 @@
"cell_type": "code",
"collapsed": false,
"input": [
+ "class EmcCollectionFactory:\n",
+ " def __init__(self):\n",
+ " pass\n",
+ "\n",
+ " def create(self,type):\n",
+ " pass\n",
"\n",
+ " def createArray(self):\n",
+ " pass\n",
"\n",
"factory = EmcCollectionFactory()\n",
- "collection = factory.create(ArrayId)\n",
+ "collection = factory.create(\"Array\")\n",
"collection.insert(42); # EmcArrayCollection::insert() is called\n",
"print collection"
],
@@ -157,17 +155,14 @@
"metadata": {},
"outputs": [
{
- "ename": "NameError",
- "evalue": "name 'EmcCollectionFactory' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m '''\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mfactory\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mEmcCollectionFactory\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mcollection\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfactory\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcreate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mArrayId\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mcollection\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minsert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m42\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m \u001b[0;31m# EmcArrayCollection::insert() is called\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'EmcCollectionFactory' is not defined"
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "None\n"
]
}
],
- "prompt_number": 4
+ "prompt_number": 32
},
{
"cell_type": "markdown",
@@ -364,27 +359,25 @@
"collapsed": false,
"input": [
"\n",
+ "class EmcCollectionFactory:\n",
+ " def __init__(self):\n",
+ " pass\n",
"\n",
+ " def create(self,type):\n",
+ " pass\n",
+ "\n",
+ " def createArray(self):\n",
+ " pass\n",
+ " \n",
"factrory = EmcCollectionFactory()\n",
- "collection = factory.create(ArrayId);\n",
+ "collection = factory.create(\"Array\");\n",
"if (not collection.isFull()):\n",
" collection.insert(42);"
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "NameError",
- "evalue": "name 'EmcCollectionFactory' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m '''\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mfactrory\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mEmcCollectionFactory\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mcollection\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfactory\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcreate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mArrayId\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;32mnot\u001b[0m \u001b[0mcollection\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0misFull\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'EmcCollectionFactory' is not defined"
- ]
- }
- ],
- "prompt_number": 11
+ "outputs": [],
+ "prompt_number": 36
},
{
"cell_type": "markdown",
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb
index a4d7907e..c8f2cfb1 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb
@@ -26,26 +26,18 @@
"cell_type": "code",
"collapsed": false,
"input": [
+ "import socket\n",
+ "import sys\n",
+ "import os\n",
+ "sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM,0)\n",
"\n",
- "socketfd = socket(AF_UNIX, SOCK_STREAM, 0);\n",
- "if(socketfd < 0):\n",
+ "if(sock < 0):\n",
" pass"
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "NameError",
- "evalue": "name 'socket' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;34m//\u001b[0m \u001b[0mcreate\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m '''\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0msocketfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mAF_UNIX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSOCK_STREAM\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0;32mif\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msocketfd\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'socket' is not defined"
- ]
- }
- ],
- "prompt_number": 1
+ "outputs": [],
+ "prompt_number": 7
},
{
"cell_type": "markdown",
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb
index a23bdf0e..8bf2f3f0 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb
@@ -262,24 +262,22 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\n",
+ "\"\"\"\n",
"def SQUARE(x):\n",
" return x*x\n",
"i = SQUARE(\"hello\");\n",
- "print i"
+ "print i\n",
+ "\"\"\""
],
"language": "python",
"metadata": {},
"outputs": [
{
- "ename": "TypeError",
- "evalue": "can't multiply sequence by non-int of type 'str'",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mSQUARE\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSQUARE\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"hello\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36mSQUARE\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 5\u001b[0m '''\n\u001b[1;32m 6\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mSQUARE\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSQUARE\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"hello\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mTypeError\u001b[0m: can't multiply sequence by non-int of type 'str'"
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 10,
+ "text": [
+ "'\\ndef SQUARE(x):\\n return x*x\\ni = SQUARE(\"hello\");\\nprint i\\n'"
]
}
],
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb
index 32ad5666..62a8a475 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb
@@ -336,25 +336,14 @@
"collapsed": false,
"input": [
"\n",
- "pid1 = fork(); # NO: should use pid_t\n",
+ "#pid1 = fork(); # NO: should use pid_t\n",
"\n",
- "pid2 = fork();"
+ "#pid2 = fork();"
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "NameError",
- "evalue": "name 'fork' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mNote\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0mIt\u001b[0m \u001b[0mwould\u001b[0m \u001b[0mshoot\u001b[0m \u001b[0merror\u001b[0m \u001b[0mbecause\u001b[0m \u001b[0mfork\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mdefined\u001b[0m \u001b[0mhere\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m '''\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mpid1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfork\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m \u001b[0;31m# NO: should use pid_t\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mpid2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfork\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'fork' is not defined"
- ]
- }
- ],
- "prompt_number": 12
+ "outputs": [],
+ "prompt_number": 2
},
{
"cell_type": "markdown",
@@ -439,29 +428,28 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "\n",
+ "\"\"\"\n",
"i = 0;\n",
"for i in range(last()):\n",
" pass\n",
"\n",
"for i in range(first()):\n",
- " pass"
+ " pass\n",
+ " \"\"\""
],
"language": "python",
"metadata": {},
"outputs": [
{
- "ename": "NameError",
- "evalue": "name 'last' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m/home/jay/\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m '''\n\u001b[1;32m 6\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlast\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mNameError\u001b[0m: name 'last' is not defined"
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 5,
+ "text": [
+ "'\\ni = 0;\\nfor i in range(last()):\\n pass\\n\\nfor i in range(first()):\\n pass\\n '"
]
}
],
- "prompt_number": 16
+ "prompt_number": 5
},
{
"cell_type": "markdown",
diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb
index 8660012f..a2d1bd52 100755
--- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb
+++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb
@@ -29,24 +29,13 @@
"collapsed": false,
"input": [
"\n",
- "import EmcArray # EmcArray.py\n",
- "import iostream # The rest of the EmcArray.cc file "
+ "#import EmcArray # EmcArray.py\n",
+ "#import iostream # The rest of the EmcArray.cc file "
],
"language": "python",
"metadata": {},
- "outputs": [
- {
- "ename": "ImportError",
- "evalue": "No module named EmcArray",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mNote\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mwould\u001b[0m \u001b[0mgive\u001b[0m \u001b[0merror\u001b[0m \u001b[0mbecause\u001b[0m \u001b[0mwe\u001b[0m \u001b[0mdont\u001b[0m \u001b[0mhave\u001b[0m \u001b[0mEmcArray\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0miostream\u001b[0m \u001b[0mpackages\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m '''\n\u001b[1;32m----> 6\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mEmcArray\u001b[0m \u001b[1;31m# EmcArray.py\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0miostream\u001b[0m \u001b[1;31m# The rest of the EmcArray.cc file\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mImportError\u001b[0m: No module named EmcArray"
- ]
- }
- ],
- "prompt_number": 1
+ "outputs": [],
+ "prompt_number": 2
},
{
"cell_type": "heading",
--
cgit