Yesterday didn't do it, suddenly I want to try Python, I went to an interpreter and found this book.
This website is good, Python.cn Chinese community, rich information.
1. Phthon is a scripting language, does not need to be compiled, run through the interpreter. The classic HelloWorld program is as follows "Hello World" very simple, simple - is Python's philosophy! We know that although Java says "Everything is Object", it is actually supporting basic types such as int, Double Based on Stack static type, but Python truly all is an object, so that I am amazed is actually a function, the type itself is also a function. Object, even the running stack of the program itself is also an object. Haha, it is really fun.
2. PPYTHON has no type, or dynamically determines the type, there are three advanced data structures: list, sequence, dictionary. Python is not inherently not type, which can be divided into variable types (dictionary, list) and non-variable types (integer, string, etc.).
3. Physhon has its own properties, and the instance of the class also has its own properties, both have no direct contact. The attribute of the class instance changes the type assigned by the attribute assigned by the class instance, in order to avoid confusion attributes and class instances, the following 3 rules should be observed.
a. Attribute declaration of class instance is best declared in __init () __ function
b. The name of the attribute of the class instance is not the same as the attribute name of the class.
c. Attributes of class instances are best modified to be private, access them with Get (), set () method
4 .__ init () __ can view the structure of the class, in fact, it is not a constructor, it is the first code executed by the class instance, which looks "like" is a constructor, saying it is not because it is before it Objects have been constructed, this is very interesting. DEL is equivalent to the destructor in C , but Del is first destroyed by the object's reference, so that this reference is unacceptable, the object's reference is reduced, and if the reference count is 0, this object is destroyed. Del and Java's Finalize () is very similar to the cleanup work before destroying the object, but Java does not allow you to interfere with the recycling process of the object.
5.Reflecting. Reflective mechanism, dynamically obtain information of the object. The main function type (), DIR (), STR () In addition, the function itself is an object, can be used as a parameter into another function (this is the same as the function pointer does not know if it is the same?) The reflecting. Parameter (ClassType), Inheritance system (__bases__ attribute)
The above is a little less than yesterday, Python's class library is not familiar, this is what I understand in my next stage. Personally think that the dynamic language is a trend of language development, I don't have a lot of quite refreshing when using PHP write scripts :) Everyone plays Python when using Java, Ruby is also good, huh ~