「逆引きPython/クラスとオブジェクト」の編集履歴(バックアップ)一覧はこちら

逆引きPython/クラスとオブジェクト」(2009/08/02 (日) 13:19:11) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

#contents(fromhere=true) **クラスの例 class MyClass(BaseClass1,BaseClass2): def __init__(self): self.data = [] class MyStack: def __init__(self): self.data = list() def push(self,x): self.data.append(x) def pop(self): return self.data.pop() def clear(self): self.data = list() def size(self): return len(self.data) stack = MyStack() stack.push(4) stack.push(5) stack.push(8) print(stack.size()) #3 print(stack.pop()) #8 print(stack.size()) #2 stack.clear() print(stack.size()) #0 class MyTestClass: def __init__(self): self.__count = 0 def inc(self): self.__count += 1 def dec(self): if self.__count > 0: self.__count -= 1 def getcount(self): return self.__count test = MyTestClass() test.inc() test.inc() print(test.getcount()) #2 test.dec() print(test.getcount()) #1 test.dec() test.dec() print(test.getcount()) #0 print(test.__count) #Error ----
#contents(fromhere=true) **クラスの例 class MyClass(BaseClass1,BaseClass2): def __init__(self): self.data = [] class MyStack: def __init__(self): self.data = list() def push(self,x): self.data.append(x) def pop(self): return self.data.pop() def clear(self): self.data = list() def size(self): return len(self.data) stack = MyStack() stack.push(4) stack.push(5) stack.push(8) print(stack.size()) #3 print(stack.pop()) #8 print(stack.size()) #2 stack.clear() print(stack.size()) #0 class MyTestClass: def __init__(self): self.__count = 0 def inc(self): self.__count += 1 def dec(self): if self.__count > 0: self.__count -= 1 def getcount(self): return self.__count test = MyTestClass() test.inc() test.inc() print(test.getcount()) #2 test.dec() print(test.getcount()) #1 test.dec() test.dec() print(test.getcount()) #0 print(test.__count) #Error ----

表示オプション

横に並べて表示:
変化行の前後のみ表示: