-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractClass.py
More file actions
executable file
·41 lines (34 loc) · 1.05 KB
/
AbstractClass.py
File metadata and controls
executable file
·41 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
#
# \file AbstractClass.py
# \brief
#
import abc
#--------------------------------------------------------------------------------------------------
class IInretface(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def foo(self):
pass
class A(IInretface):
pass
class B(A):
def foo(self):
return super(B, self).foo()
#--------------------------------------------------------------------------------------------------
a = A()
"""
Traceback (most recent call last):
File "./AbstractClass.py", line 21, in <module>
a = A()
TypeError: Can't instantiate abstract class A with abstract methods foo
"""
#--------------------------------------------------------------------------------------------------
interface = IInretface()
"""
Traceback (most recent call last):
File "./AbstractClass.py", line 20, in <module>
interface = IInretface()
TypeError: Can't instantiate abstract class IInretface with abstract methods foo
"""
#--------------------------------------------------------------------------------------------------