Chapter One : Naming

EXAMPLE 1.1 Page no : 2

In [1]:
strL = 0  # Not recommended
stringLength = 0 # Recommended

Example 2 Page no : 3

In [2]:
class EmcFruit:
    def print_(self):
        pass

class EmcApple(EmcFruit):
    def print_(self):
        pass

fp = EmcApple()
print fp 
<__main__.EmcApple instance at 0x9d29c8c>

EXAMPLE 1.3 Page no : 4

In [3]:
class Point:
    def __init__(self,a,b):
        self.x = a
        self.y = b
    def x1(self,a):
        self.x = a

p = Point(0,0) # a point in a 2-dimensional space
p.x1(1); # set X-coordinate
print  p.x  # prints X-coordinate, "1"
1

EXAMPLE 1.4 page no : 4

In [4]:
def check_assign(a,i,t):
    if (i < len(a)):
        a[i] = t;

EXAMPLE 1.5 Page no : 6

In [5]:
class String:
    pass

class DynamicArray:
    pass

EXAMPLE 1.6 page no : 6

In [6]:
a = 'aaa' 
s1 = 'xyz'
s = 'abc' # Emc::String s;

EXAMPLE 1.8 page no : 7

In [4]:
#s1 = EmcString() # Belongs to the Emc Class Library
#s2 = OtherString() # Belongs to the Other Class Library

EXAMPLE 1.9 Page no : 8

In [5]:
#import RWCstring #include "RWCstring.h" /* Recommended */
#from rw import cstring #include "rw/cstring.h" /* Sometimes needed */

EXAMPLE 1.10 page no : 9

In [9]:
i__j = 11;
_K = 22;
_m = 33;
In [ ]: