- 博客(12)
- 收藏
- 关注
原创 About Exception
1) rise exceptionTo raise an exception, you use the raise statement with an argument that is either a class (which should subclass Exception for the "catch clause") or an instance.>>> raise Ex
2013-05-31 22:54:12 786
原创 Multiple inheritance
class Calculator: def calculate(self, expression): self.value = eval(expression)class Talker: def talk(self): print 'Hi, my value is', self.valueclass TalkingCalculat
2013-05-31 22:47:47 827
原创 Some function to handle class and its interface info
1) get some class infothe following example show basic inheritanceclass Filter: def init(self): self.blocked = [] def filter(self, sequence): return [x for x in s
2013-05-31 22:41:13 796
原创 The Meaning of Class Definitions
we have to keep in mind that the meaning of class definitions are simply code sections that are executed !>>>class C: print 'Class C being defined...'Class C being defined...>>>class Me
2013-05-31 22:17:10 847
原创 About Class
1) method and functionOne big difference between methods and other functions is that methods always receive the object they are part of as their first argument, usually called self.>>> class Class
2013-05-31 21:55:48 821
原创 Parameters
1)positional,keyword and default parameterFor positional parameters,values are assigned to different parameters according to their positions; def hello_1(greeting, name): print '%s, %s!' %
2013-05-26 09:23:05 993
原创 Scope
The problem of shadowingReading the value of global variables is not a problem in general, but one thing may make it problematic. If a local variable or parameter exists with the same name as the gl
2013-05-26 08:32:10 717
原创 Three special statements: pass, del, and exec
1)Nothing Happened by pass Sometimes you need to do nothing. This may not be very often, but when it happens, it's good to know that you have the pass statement:>>> pass>>>another example:
2013-05-26 08:14:03 1167
原创 Some iteration utilities
Python has several functions that can be useful when iterating over a sequence (or other iterable object). Some of these are available in the itertools module , but there are some built-in functions
2013-05-25 22:38:33 820
原创 About typeid()
#include #include using namespace std;class A{public: virtual void haha(){}};class B :public A{};int main() { A* a = new B; cout<< typeid(a).name()<<endl; cout<< typeid(*a).name
2013-05-02 22:25:54 611
原创 RTTI
RTTI(run-time type identification) ,like exceptions ,depends on type information residing in the virtual function table. If you try to use RTTI on a class that has no virtual functions, you will get
2013-05-02 22:04:20 803
原创 About exception
1 clear up in the try{ }catch{ }if exception happen, the system first clear up the objects which have been created in the try block,then go into the catch block;if objects in array happen error d
2013-05-02 21:57:52 670
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人