by Xiaokang Zhang | Jun 16, 2018 | Computer Science
Iteration Python support iteration, for example, iterating over a list: for elem in [1, 2, 3]: print elem Iterating over a dict: for key in {‘Google’: ‘G’, ‘Yahoo’: ‘Y’, ‘Microsoft’: ‘M’}: print...
by Xiaokang Zhang | Jun 12, 2018 | Computer Science
Python supports context management. Which often used when handling resources, for example, file, network connection. With statement helps make sure the resources are cleaned up or released. There are two major functions for context management: __enter__ and __exit__....
by Xiaokang Zhang | Jun 9, 2018 | Computer Science
The following is an example of python closure. def outer_function(outter_arg): closure_var = outter_arg def inner_function(inner_arg): print(“{} {}”.format(closure_var, inner_arg)) return inner_function # Usage of a python closure closure_func =...
by Xiaokang Zhang | Jun 4, 2018 | Sociology
为什么不同国家不同地区的文化相差如此之大?为什么当代的文化与古代甚至近代的文化这么不同?文化的演进是完全随机的吗?还是说存在着某种共同的推动力量?...