Python Class wz/wzout initialization

Simple code:

Python Class wz/wzout initialization_第1张图片

Notice of writting class:

1). Begin with 'class' keyword;

2). ALLWAYS Capitalize the First Letter of class Name; 

3). Create class instance just like calling a function.

4). Self used to attach variables and functions to a class; if the 'self' missing, then 'TypeError' occurs:

            TypeError: functionName() takes no arguments....

5). in Python 3.x.x , to use parenthesis '()' after 'print'; EX:

                                  print("something balalalalallallallalla")


Initialization:

1). Also called Constructor;

2). Function RUN when class instance created;

Example class code with 'SELF' initialization and function calls shown as below:

'Good' and 'Bad' when initialization with 'SELF' in class


To call a function within the same class
Class code with 'SELF' - Part 1
Class code with 'SELF' - Part 2
Class code without 'SELF' - Final

你可能感兴趣的:(Python Class wz/wzout initialization)