gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / input / func_init_vars.py @ 745
History | View | Annotate | Download (1004 Bytes)
1 |
"""Checks that class variables are seen as inherited !
|
---|---|
2 |
"""
|
3 |
# pylint: disable=too-few-public-methods
|
4 |
from __future__ import print_function |
5 |
|
6 |
|
7 |
class MyClass(object): |
8 |
"""Inherits from nothing
|
9 |
"""
|
10 |
|
11 |
def __init__(self): |
12 |
self.var = {}
|
13 |
|
14 |
def met(self): |
15 |
"""Checks that base_var is seen as defined outside '__init__'
|
16 |
"""
|
17 |
self.var[1] = 'one' |
18 |
self.base_var = 'one' |
19 |
print(self.base_var, self.var) |
20 |
|
21 |
def met2(self): |
22 |
"""dummy method"""
|
23 |
print(self)
|
24 |
class MySubClass(MyClass): |
25 |
"""Inherits from MyClass
|
26 |
"""
|
27 |
class_attr = 1
|
28 |
|
29 |
def __init__(self): |
30 |
MyClass.__init__(self)
|
31 |
self.var2 = 2 |
32 |
print(self.__doc__)
|
33 |
print(self.__dict__)
|
34 |
print(self.__class__)
|
35 |
|
36 |
def met2(self): |
37 |
"""Checks that var is seen as defined outside '__init__'
|
38 |
"""
|
39 |
self.var[1] = 'one' |
40 |
self.var2 += 1 |
41 |
print(self.class_attr)
|
42 |
|
43 |
if __name__ == '__main__': |
44 |
OBJ = MyClass() |
45 |
OBJ.met() |