`

class and inheritance

    博客分类:
  • PHP
阅读更多
class and inheritance

class Base:
	def __init__(self):
		self.data = []
	def add(self, x):
		self.data.append(x)
	def addtwice(self, x):
		self.add(x)
		self.add(x)
		

# Child extends Base
class Child(Base):
	def plus(self,a,b):
		return a+b
		
oChild=Child()
oChild.add("str1")
oChild.addtwice("up");
print oChild.data
print oChild.plus(2,3)
print str(type(oChild.data))
print type(oChild.data)


U:\code>python tt.py
['str1', 'up', 'up']
5
<type 'list'>
<type 'list'>
分享到:
评论

相关推荐

    Define inheritance classes Car, Bus, Truck and Motor in the files Car.java, Bus.java,

    The class Bus should include data members that hold the following information: Bus type (should be one of Small, Medium, Large types), number of seats. Define necessary methods in the class Bus.

    Jpaca 帮助文档 Jpcap API EN.CHM

    Class inheritance diagram Direct Subclasses All Known Subinterfaces All Known Implementing Classes Class/interface declaration Class/interface description Nested Class Summary Field Summary ...

    Learning Android: Develop Mobile Apps Using Java and Eclipse(第二版)

    Interfaces and Inheritance Collections Generics Threads Summary Chapter 3 The Stack Stack Overview Linux Native Layer Dalvik Application Framework Applications Summary Chapter 4 Installing and ...

    Objective-C头文件导出工具class-dump

    -I sort classes, categories, and protocols by inheritance (overrides -s) -o &lt;dir&gt; output directory used for -H -r recursively expand frameworks and fixed VM shared libraries -s sort classes and ...

    Code Visualizer 4.57

    • Show each class and struct's inheritance, reference and use relation. • Show total class inheritance, reference and use relation. • Show whole project's statistics such as class count, function ...

    ExceptionalCpp_47EngineeringPuzzlesProgrammingProblemsSol.chm

    Robust class design and inheritance Compiler firewalls and the Pimpl Idiom Name lookup, namespaces, and the Interface Principle Memory management issues and techniques Traps, pitfalls, and anti-...

    Data Structures And Algorithms With Object-Oriented Design Patterns In C Sharp.pdf

    polymorphism and inheritance can be used effectively. In addition, algorithmic abstraction is used extensively when presenting classes of algorithms. By using algorithmic abstraction, it is possible ...

    PHP Objects, Patterns, and Practice(Apress,2016)

    It introduces key topics including class declaration, inheritance, reflection and much more. The next section is devoted to design patterns. It explains the principles that make patterns powerful. ...

    ModelMaker.Code.Explorer.v8.0.0.1877.part1

    As a Class Browser it shows classes (inheritance) and members (fields, methods, properties) in two filtered views, similar to the windows explorer. On the left the Explorer docked in the IDE editor. ...

    ModelMaker.Code.Explorer.v8.0.0.1877.part2

    As a Class Browser it shows classes (inheritance) and members (fields, methods, properties) in two filtered views, similar to the windows explorer. On the left the Explorer docked in the IDE editor. ...

    abstractproduct_0_2.tar.gz_inheritance

    It does so by static initialization of meta-classes and factory objects reflecting your own class hierarchy (derived from AbstarctProduct class). No multiple inheritance yet. No constructor arguments...

    Object Oriented.PHP - Concepts Techniques and Code

    Chapter 10: Improvement Through Inheritance Chapter 11: Advanced Object-Oriented Programming Concepts Chapter 12: Keeping It Fresh Chapter Chapter 14: Creating Documentation Using the Reflection ...

    软件需求分析英文课件

    Generalization and inheritance Abstract class Interface © Pearson Education 2007 Appendix (Maciaszek - RASD 3/e) 3 Object has State Behavior Identity (equal identical) Objects and ...

    Selected.Topics.in.Cplusplus.15117

    Structs, Classes and their Inheritance Object Construction Pointers Non-Constructible, Non-Copyable Class Understanding new Understanding Constructors Forward Declarations, Compiling and Linking Copy ...

    PHP Objects, Patterns, and Practice, 4th Edition

    It introduces key topics including class declaration, inheritance, reflection and much more. These provide the fundamentals of the PHP’s support for objects. It also introduces some principles of ...

    ssd3,Exercise3

    ssd3,Exercise3的习题,帮助大家学习Java。...• Implementing the constructors, accessors, and mutators of a Java class • Using inheritance to implement a specialization/generalization relationship

    Pro C# 7: With .NET and .NET Core

    Chapter 6: Understanding Inheritance and Polymorphism Chapter 7: Understanding Structured Exception Handling Chapter 8: Working with Interfaces Part IV: Advanced C# Programming Chapter 9: Collections...

    MMX_Setup_15_0_20_2385.zip

    As a Class Browser it shows classes (inheritance) and members (fields, methods, properties) in two filtered views, similar to the windows explorer. On the left the Explorer docked in the IDE editor. ...

    Learn.JAVA.PROGRAMMING.from.scratch.B0140CLLFG

    Chapter 5: Inheritance (Abstract class and Interface) Chapter 6: Data types Chapter 7: Object comparison Chapter 8: Data Structures and their operations Chapter 9: Exceptions and Errors Chapter 10: ...

Global site tag (gtag.js) - Google Analytics