Rapid GUI Programming with Python and Qt Classes and Modules By Raed S. Rasheed Classes and Modules By Raed S. Rasheed 1.

Slides:



Advertisements
Similar presentations
Sprites A sprite is a 2D image or animation that is integrated into a larger scene. Originally, sprites were created by special hardware that would super-impose.
Advertisements

Python Objects and Classes
Rapid GUI Programming with Python and Qt Classes and Modules By Raed S. Rasheed Classes and Modules By Raed S. Rasheed 1.
Lilian Blot BUILDING CLASSES Java Programming Spring 2014 TPOP 1.
Classes and Inheritance. 2 As the building blocks of more complex systems, objects can be designed to interact with each other in one of three ways: Association:
Genome 559: Introduction to Statistical and Computational Genomics Elhanan Borenstein Classes and Objects Object Oriented Programming.
Creating your own classes class Elephant(object): """A virtual pet""" def __init__(self, name, age, weight, trunkradius, trunklength): self.name = name.
Recitation 6 Programming for Engineers in Python.
Classes Special thanks to Roy McElmurry, Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise noted, this.
Python 3 Some material adapted from Upenn cis391 slides and other sources.
Python classes: new and old. New and classic classes  With Python 2.2, classes and instances come in two flavors: old and new  New classes cleaned up.
Guide to Programming with Python
Unit 8 Classes and Objects; Inheritance Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except.
REFERENCES: CHAPTER 8 Object-Oriented Programming (OOP) in Python.
Python 3 Some material adapted from Upenn cis391 slides and other sources.
Python Crash Course Classes 3 rd year Bachelors V1.0 dd Hour 7.
1 Python Control of Flow and Defining Classes LING 5200 Computational Corpus Linguistics Martha Palmer.
Inheritance. Inhertance Inheritance is used to indicate that one class will get most or all of its features from a parent class. class Dog(Pet): Make.
Python Programming Chapter 14: Classes and Methods Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Chapter 11 Introduction to Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
11/27/07. >>> Overview * objects * class * self * in-object methods * nice printing * privacy * property * static vs. dynamic * inheritance.
New-Style Classes Thomas Wouters XS4ALL #python.
CS61A Lecture 15 Object-Oriented Programming, Mutable Data Structures Jom Magrotker UC Berkeley EECS July 12, 2012.
Guide to Programming with Python
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Computer Science 111 Fundamentals of Programming I Model/View/Controller and Data model design.
Python Programming in Context Chapter 12. Objectives To introduce the concept of inheritance To create a working object-oriented graphics package To provide.
Computer Science 112 Fundamentals of Programming II Interfaces and Implementations.
CLASSES Python Workshop. Introduction  Compared with other programming languages, Python’s class mechanism adds classes with a minimum of new syntax.
P YTHON ’ S C LASSES Ian Wynyard. I NTRODUCTION TO C LASSES A class is the scope in which code is executed A class contains objects and functions that.
1 Programming for Engineers in Python Autumn Lecture 6: More Object Oriented Programming.
Objects and Classes Procedural Programming A series of functions performing specific tasks Data items are passed from one function to another by arguments.
Chapter Object Oriented Programming (OOP) CSC1310 Fall 2009.
Classes COMPSCI 105 SS 2015 Principles of Computer Science.
Guide to Programming with Python Chapter Eight (Part I) Object Oriented Programming; Classes, constructors, attributes, and methods.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 12 Inheritance and Class Design 1.
Python – May 19 Review –What is the difference between: list, tuple, set, dictionary? –When is it appropriate to use each? Creating our own data types:
Chapter 17 Q and A Victor Norman, et al. CS104. What is Object-oriented Programming? Q: What is object-oriented programming? A: It means defining classes/objects,
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Making our own Classes and objects  As in real life, we’re now creating classes of objects.  a class that defines basic characteristics and functions.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Object Oriented Programming(Objects& Class) Classes are an expanded concept of data structures: like.
Q and A for Sections 6.2, 6.3 Victor Norman CS106.
INTRO2CS Tirgul 8 1. What We’ll Be Seeing Today  Introduction to Object-Oriented Programming (OOP).  Using Objects  Special methods 2.
Object-Oriented Programming (OOP) in Python References: Chapter 8.
EECS 110: Lec 15: Classes and Objects (2)
Classes and Objects; Inheritance
COMPSCI 107 Computer Science Fundamentals
CSSE 120—Rose Hulman Institute of Technology
Software Development Java Classes and Methods
Fundamentals of Programming II Equality and Multiple Inheritance
Fundamentals of Programming II Interfaces and Implementations
Lecture VI Objects The OOP Concept Defining Classes Methods
Creating and Deleting Instances Access to Attributes and Methods
CHAPTER FIVE Classes.
Introduction to Object-Oriented Programming (OOP) II
Classes Special thanks to Roy McElmurry, Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise noted, this.
Built-In Functions Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise noted, this work.
Fundamentals of Programming I Commonly Used Methods More Modeling
Fundamentals of Programming I Windows, Labels, and Command Buttons
Conrad Huang Genentech Hall, N453A x6-0415
Fundamentals of Programming I More Data Modeling
CSC1018F: Object Orientation, Exceptions and File Handling (Tutorial)
Python classes: new and old
EECS 110: Lec 15: Classes and Objects (2)
Lecture 18 Python OOP.
Python classes: new and old
Making our own Classes and objects
Introduction to Object-Oriented Programming (OOP)
Introduction to Object-Oriented Programming (OOP) II
Week 2 Classes and Objects
Presentation transcript:

Rapid GUI Programming with Python and Qt Classes and Modules By Raed S. Rasheed Classes and Modules By Raed S. Rasheed 1

Classes and Modules Python fully supports procedural and object-oriented programming The syntax for creating a class is simple: class className(base_classes): suite Python fully supports procedural and object-oriented programming The syntax for creating a class is simple: class className(base_classes): suite 2

Creating Instances Python has the __new__() special method which is called to construct an object, Python has the __new__() special method which is called to construct an object, the __init__() special method which is called to initialize a newly constructed object. the __init__() special method which is called to initialize a newly constructed object. When an object is about to be garbage-collected its __del__() special method is called, with self as its only argument. When an object is about to be garbage-collected its __del__() special method is called, with self as its only argument. We will create one that stores a string (the name of a kind of chair) and a number (how many legs the chair has): class Chair(object): """This class represents chairs.""" def __init__(self, name, legs=4): self.name = name self.legs = legs Python has the __new__() special method which is called to construct an object, Python has the __new__() special method which is called to construct an object, the __init__() special method which is called to initialize a newly constructed object. the __init__() special method which is called to initialize a newly constructed object. When an object is about to be garbage-collected its __del__() special method is called, with self as its only argument. When an object is about to be garbage-collected its __del__() special method is called, with self as its only argument. We will create one that stores a string (the name of a kind of chair) and a number (how many legs the chair has): class Chair(object): """This class represents chairs.""" def __init__(self, name, legs=4): self.name = name self.legs = legs 3

Creating Instances To create an instance of a class, we use the following syntax: instance = className(arguments) for example: chair1 = Chair("Barcelona") chair2 = Chair("Bar Stool", 1) Since the attributes are public, they can be read or assigned to using the dot (.) operator; for example: print chair2.name will print “Bar Stool”, and chair1.legs = 2 will change chair1’s legs attribute’s value from 4 to 2. To create an instance of a class, we use the following syntax: instance = className(arguments) for example: chair1 = Chair("Barcelona") chair2 = Chair("Bar Stool", 1) Since the attributes are public, they can be read or assigned to using the dot (.) operator; for example: print chair2.name will print “Bar Stool”, and chair1.legs = 2 will change chair1’s legs attribute’s value from 4 to 2. 4

Methods and Special Methods class Rectangle(object): def __init__(self, width, height): self.width = width self.height = height def getWidth(self): return self.width def setWidth(self, width): self.width = width def getHeight(self): return self.height def setHeight(self, height): self.height = height def area(self): return self.getWidth() * self.getHeight() class Rectangle(object): def __init__(self, width, height): self.width = width self.height = height def getWidth(self): return self.width def setWidth(self, width): self.width = width def getHeight(self): return self.height def setHeight(self, height): self.height = height def area(self): return self.getWidth() * self.getHeight() 5

Methods and Special Methods rect = Rectangle(50, 10) print rect.area() # Prints "500" rect.setWidth(20) rect = Rectangle(50, 10) print rect.area() # Prints "500" rect.setWidth(20) 6

Methods and Special Methods property() function class Rectangle(object): def __init__(self, width, height): self.width = width self.height = height def _area(self): return self.width * self.height area = property(fget=_area) property() function class Rectangle(object): def __init__(self, width, height): self.width = width self.height = height def _area(self): return self.width * self.height area = property(fget=_area) 7

Methods and Special Methods rect = Rectangle(5, 4) print rect.width, rect.height, rect.area # Prints (5, 4, 20) rect.width = 6 rect = Rectangle(5, 4) print rect.width, rect.height, rect.area # Prints (5, 4, 20) rect.width = 6 8

Methods and Special Methods def _width(self): return self.__width def _setWidth(self, width): # Perform some computation self.__width = width width = property(fget=_width, fset=_setWidth) def _width(self): return self.__width def _setWidth(self, width): # Perform some computation self.__width = width width = property(fget=_width, fset=_setWidth) 9

Methods and Special Methods class Rectangle(object): def __init__(self, width, height): self.__width = width self.__height = height def _area(self): return self.__width * self.__height area = property(fget=_area) def _height(self): return self.__height def _setHeight(self, height): self.__height = height height = property(fget=_height, fset=_setHeight) height = property(fget=_height, fset=_setHeight) class Rectangle(object): def __init__(self, width, height): self.__width = width self.__height = height def _area(self): return self.__width * self.__height area = property(fget=_area) def _height(self): return self.__height def _setHeight(self, height): self.__height = height height = property(fget=_height, fset=_setHeight) height = property(fget=_height, fset=_setHeight) 10

Methods and Special Methods def _width(self): def _width(self): return self.__width return self.__width def _setWidth(self, width): def _setWidth(self, width): self.__width = width self.__width = width width = property(fget=_width, fset=_setWidth) def __cmp__(self, other): return cmp(self.area, other.area) def __nonzero__(self): return self.__width or self.__height def __repr__(self): return "Rectangle(%d, %d)" % (self.__width, self.__height) def _width(self): def _width(self): return self.__width return self.__width def _setWidth(self, width): def _setWidth(self, width): self.__width = width self.__width = width width = property(fget=_width, fset=_setWidth) def __cmp__(self, other): return cmp(self.area, other.area) def __nonzero__(self): return self.__width or self.__height def __repr__(self): return "Rectangle(%d, %d)" % (self.__width, self.__height) 11

Methods and Special Methods print ("Starting..\n") rect1 = Rectangle(4,5) print ("Area is [",rect1.area,"]") print ("Set width to [ 7 ] and height to [ 2 ]") rect1.width = 7 rect1.height = 2 print ("Now area is [",rect1.area,"]") print ("\nFinishing..") print ("Starting..\n") rect1 = Rectangle(4,5) print ("Area is [",rect1.area,"]") print ("Set width to [ 7 ] and height to [ 2 ]") rect1.width = 7 rect1.height = 2 print ("Now area is [",rect1.area,"]") print ("\nFinishing..") 12

Methods and Special Methods Output:-Starting.. Area is [ 20 ] Set width to [ 7 ] and height to [ 2 ] Now area is [ 14 ] Finishing..Output:-Starting.. Area is [ 20 ] Set width to [ 7 ] and height to [ 2 ] Now area is [ 14 ] Finishing.. 13

Methods and Special Methods Method Syntax Description __init__(self, args) x = X() Initializes a newly created instance __call__(self, args) x() Makes instances callable, that is,turns them into functors. The args are optional. __cmp__(self, other)x == y x < y # etc Returns -1 if self < other, 0 if they are equal, and 1 otherwise. If __cmp__() is implemented, it will be used for any comparison operators that are not explicitly implemented. __eq__(self, other) x == y Returns True if x is equal to y __ne__(self, other)x != y Returns True if x is not equal to y __le__(self, other) x <= y Returns True if x is less than or equal to y Method Syntax Description __init__(self, args) x = X() Initializes a newly created instance __call__(self, args) x() Makes instances callable, that is,turns them into functors. The args are optional. __cmp__(self, other)x == y x < y # etc Returns -1 if self < other, 0 if they are equal, and 1 otherwise. If __cmp__() is implemented, it will be used for any comparison operators that are not explicitly implemented. __eq__(self, other) x == y Returns True if x is equal to y __ne__(self, other)x != y Returns True if x is not equal to y __le__(self, other) x <= y Returns True if x is less than or equal to y 14

Methods and Special Methods Method Syntax Description __lt__(self, other) x < y Returns True if x is less than y __ge__(self, other) x >= y Returns True if x is greater than or equal to y __gt__(self, other) x > y Returns True if x is greater than y __nonzero__(self) if x: passReturns True if x is nonzero passReturns True if x is nonzero __repr__(self) y = eval(`x`) Returns an eval()-able representation of x. Using backticks is the same as calling repr(). __str__(self) print x Returns a human-readable representation of x __unicode__(self) print x Returns a human-readable Unicode representation of x Method Syntax Description __lt__(self, other) x < y Returns True if x is less than y __ge__(self, other) x >= y Returns True if x is greater than or equal to y __gt__(self, other) x > y Returns True if x is greater than y __nonzero__(self) if x: passReturns True if x is nonzero passReturns True if x is nonzero __repr__(self) y = eval(`x`) Returns an eval()-able representation of x. Using backticks is the same as calling repr(). __str__(self) print x Returns a human-readable representation of x __unicode__(self) print x Returns a human-readable Unicode representation of x 15

Methods and Special Methods def __cmp__(self, other): return cmp(self.area(), other.area()) rectA = Rectangle(4, 4) rectB = Rectangle(8, 2) rectA == rectB # True because both have the same area rectA < rectB # False def __cmp__(self, other): if (self.width != other.width): return cmp(self.width, other.width) return cmp(self.height, other.height) def __cmp__(self, other): return cmp(self.area(), other.area()) rectA = Rectangle(4, 4) rectB = Rectangle(8, 2) rectA == rectB # True because both have the same area rectA < rectB # False def __cmp__(self, other): if (self.width != other.width): return cmp(self.width, other.width) return cmp(self.height, other.height) 16

Methods and Special Methods def __nonzero__(self): return self.width or self.height) def __repr__(self): return "Rectangle(%d, %d)" % (self.width, self.height) def __nonzero__(self): return self.width or self.height) def __repr__(self): return "Rectangle(%d, %d)" % (self.width, self.height) 17

Methods and Special Methods Method Syntax MethodSyntax __float__(self)float(x) __int__(self)int(x) __abs__(self) abs(x) __neg__(self) -x __add__(self, other) x + y__sub__(self, other) x - y __iadd__(self, other) x +=y __isub__(self, other) x -= y __radd__(self, other) y + x__rsub__(self, other) y - x __mul__(self, other) x * y__mod__(self, other)x % y __imul__(self, other) x *= y__imod__(self, other)x %= y __rmul__(self, other) y * x __rmod__(self, other) y % x __floordiv__(self, other) x // y__truediv__(self, other) x / y __ifloordiv__(self, other)x //= y __itruediv__(self, other)x /= y __rfloordiv__(self, other) y // x __rtruediv__(self, other) y / x Method Syntax MethodSyntax __float__(self)float(x) __int__(self)int(x) __abs__(self) abs(x) __neg__(self) -x __add__(self, other) x + y__sub__(self, other) x - y __iadd__(self, other) x +=y __isub__(self, other) x -= y __radd__(self, other) y + x__rsub__(self, other) y - x __mul__(self, other) x * y__mod__(self, other)x % y __imul__(self, other) x *= y__imod__(self, other)x %= y __rmul__(self, other) y * x __rmod__(self, other) y % x __floordiv__(self, other) x // y__truediv__(self, other) x / y __ifloordiv__(self, other)x //= y __itruediv__(self, other)x /= y __rfloordiv__(self, other) y // x __rtruediv__(self, other) y / x 18

Static Data, and Static Methods and Decorators class Balloon(object): unique_colors = set() def __init__(self, color): self.color = color def uniqueColorCount(): return def uniqueColors(): return Balloon.unique_colors.copy() class Balloon(object): unique_colors = set() def __init__(self, color): self.color = color def uniqueColorCount(): return def uniqueColors(): return Balloon.unique_colors.copy() 19

Static Data, and Static Methods and Decorators class Example: staticVariable = 5 staticVariable = 5print("starting\n") # Access through class print (Example.staticVariable) # prints 5 # Access through instance instance = Example() print (instance.staticVariable) # still 5 class Example: staticVariable = 5 staticVariable = 5print("starting\n") # Access through class print (Example.staticVariable) # prints 5 # Access through instance instance = Example() print (instance.staticVariable) # still 5 20

Static Data, and Static Methods and Decorators # Change within instance instance.staticVariable = 6 print (instance.staticVariable) # 6 print (Example.staticVariable) # 5 # Change through class Example.staticVariable = 7 print (instance.staticVariable) # still 6 print (Example.staticVariable) # now 7 print("\nfinishing") # Change within instance instance.staticVariable = 6 print (instance.staticVariable) # 6 print (Example.staticVariable) # 5 # Change through class Example.staticVariable = 7 print (instance.staticVariable) # still 6 print (Example.staticVariable) # now 7 print("\nfinishing") 21

Static Data, and Static Methods and Decorators class Example(object): name = "Example" name def static(): def static(): print ("%s static() called" % Example.name) print ("%s static() called" % Example.name) class Offspring1(Example): name = "Offspring1" name = "Offspring1" class Example(object): name = "Example" name def static(): def static(): print ("%s static() called" % Example.name) print ("%s static() called" % Example.name) class Offspring1(Example): name = "Offspring1" name = "Offspring1" 22

Static Data, and Static Methods and Decorators class Offspring2(Example): name = "Offspring2" name def static(): def static(): print ("%s static() called" % Example.name) print ("%s static() called" % Example.name)print("starting\n") Example.static() # prints Example Offspring1.static() # prints Example Offspring2.static() # prints Offspring2 print("\nfinishing“) class Offspring2(Example): name = "Offspring2" name def static(): def static(): print ("%s static() called" % Example.name) print ("%s static() called" % Example.name)print("starting\n") Example.static() # prints Example Offspring1.static() # prints Example Offspring2.static() # prints Offspring2 print("\nfinishing“) 23

Static Data, and Static Methods and Decorators class Example: name = "Example" name def static(cls): def static(cls): print ("%s static() called" % cls.name) print ("%s static() called" % cls.name) class Offspring1(Example): name = "Offspring1" name = "Offspring1" pass pass class Example: name = "Example" name def static(cls): def static(cls): print ("%s static() called" % cls.name) print ("%s static() called" % cls.name) class Offspring1(Example): name = "Offspring1" name = "Offspring1" pass pass 24

Static Data, and Static Methods and Decorators class Offspring2(Example): name = "Offspring2" name def static(cls): def static(cls): print ("%s static() called" % cls.name) print ("%s static() called" % cls.name)print("starting\n") Example.static() # prints Example Offspring1.static() # prints Offspring1 Offspring2.static() # prints Offspring2 print("\nfinishing") class Offspring2(Example): name = "Offspring2" name def static(cls): def static(cls): print ("%s static() called" % cls.name) print ("%s static() called" % cls.name)print("starting\n") Example.static() # prints Example Offspring1.static() # prints Offspring1 Offspring2.static() # prints Offspring2 print("\nfinishing") 25

Inheritance and Polymorphism class Item(object): def __init__(self, artist, title, year=None): def __init__(self, artist, title, year=None): self.__artist = artist self.__artist = artist self.__title = title self.__title = title self.__year = year self.__year = year def artist(self): def artist(self): return self.__artist return self.__artist def setArtist(self, artist): def setArtist(self, artist): self.__artist = artist self.__artist = artist def title(self): def title(self): return self.__title return self.__title class Item(object): def __init__(self, artist, title, year=None): def __init__(self, artist, title, year=None): self.__artist = artist self.__artist = artist self.__title = title self.__title = title self.__year = year self.__year = year def artist(self): def artist(self): return self.__artist return self.__artist def setArtist(self, artist): def setArtist(self, artist): self.__artist = artist self.__artist = artist def title(self): def title(self): return self.__title return self.__title 26

Inheritance and Polymorphism def title(self): def title(self): return self.__title return self.__title def setTitle(self, title): def setTitle(self, title): self.__title = title self.__title = title def year(self): def year(self): return self.__year return self.__year def setYear(self, year): def setYear(self, year): self.__year = year self.__year = year def __str__(self): def __str__(self): year = "" year = "" if self.__year is not None: if self.__year is not None: year = " in %d" % self.__year year = " in %d" % self.__year return "%s by %s%s" % (self.__title, self.__artist, year) return "%s by %s%s" % (self.__title, self.__artist, year) def title(self): def title(self): return self.__title return self.__title def setTitle(self, title): def setTitle(self, title): self.__title = title self.__title = title def year(self): def year(self): return self.__year return self.__year def setYear(self, year): def setYear(self, year): self.__year = year self.__year = year def __str__(self): def __str__(self): year = "" year = "" if self.__year is not None: if self.__year is not None: year = " in %d" % self.__year year = " in %d" % self.__year return "%s by %s%s" % (self.__title, self.__artist, year) return "%s by %s%s" % (self.__title, self.__artist, year) 27

Inheritance and Polymorphism class Painting(Item): def __init__(self, artist, title, year=None): def __init__(self, artist, title, year=None): super(Painting, self).__init__(artist, title, year) super(Painting, self).__init__(artist, title, year) # item.__init__(self, artist, title, year) # item.__init__(self, artist, title, year) class Sculpture(Item): def __init__(self, artist, title, year=None, material=None): def __init__(self, artist, title, year=None, material=None): super(Sculpture, self).__init__(artist, title, year) super(Sculpture, self).__init__(artist, title, year) self.__material = material self.__material = material class Painting(Item): def __init__(self, artist, title, year=None): def __init__(self, artist, title, year=None): super(Painting, self).__init__(artist, title, year) super(Painting, self).__init__(artist, title, year) # item.__init__(self, artist, title, year) # item.__init__(self, artist, title, year) class Sculpture(Item): def __init__(self, artist, title, year=None, material=None): def __init__(self, artist, title, year=None, material=None): super(Sculpture, self).__init__(artist, title, year) super(Sculpture, self).__init__(artist, title, year) self.__material = material self.__material = material 28

Inheritance and Polymorphism def material(self): def material(self): return self.__material return self.__material def setMaterial(self, material): def setMaterial(self, material): self.__material = material self.__material = material def __str__(self): def __str__(self): materialString = "" materialString = "" if self.__material is not None: if self.__material is not None: materialString = " (%s)" % self.__material materialString = " (%s)" % self.__material return "%s%s" % (super(Sculpture, self).__str__(), materialString) return "%s%s" % (super(Sculpture, self).__str__(), materialString) def material(self): def material(self): return self.__material return self.__material def setMaterial(self, material): def setMaterial(self, material): self.__material = material self.__material = material def __str__(self): def __str__(self): materialString = "" materialString = "" if self.__material is not None: if self.__material is not None: materialString = " (%s)" % self.__material materialString = " (%s)" % self.__material return "%s%s" % (super(Sculpture, self).__str__(), materialString) return "%s%s" % (super(Sculpture, self).__str__(), materialString) 29

Inheritance and Polymorphism class Title(object): def __init__(self, title) self.__title = title def title(self): return self.__title return "%s%s" % (super(Sculpture, self).__str__(), materialString) return "%s%s" % (super(Sculpture, self).__str__(), materialString) class Title(object): def __init__(self, title) self.__title = title def title(self): return self.__title return "%s%s" % (super(Sculpture, self).__str__(), materialString) return "%s%s" % (super(Sculpture, self).__str__(), materialString) 30

Inheritance and Polymorphism items = [] items.append(Painting("Cecil Collins", "The Poet", 1941)) items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917, "plaster")) items.append(Title("Eternal Springtime")) for item in items: print item.title() items = [] items.append(Painting("Cecil Collins", "The Poet", 1941)) items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917, "plaster")) items.append(Title("Eternal Springtime")) for item in items: print item.title() 31