0% found this document useful (0 votes)
27 views

Object-Oriented Python 1st Edition Irv Kalb instant download

The document provides information about the book 'Object-Oriented Python' by Irv Kalb, which focuses on mastering object-oriented programming (OOP) through building games and graphical user interfaces (GUIs). It includes a detailed table of contents outlining various chapters that cover procedural Python examples, modeling physical objects, managing multiple objects, and using OOP in game development. Additionally, it offers links to download the book and other related ebooks from the website ebookmeta.com.

Uploaded by

kobaeprofir30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Object-Oriented Python 1st Edition Irv Kalb instant download

The document provides information about the book 'Object-Oriented Python' by Irv Kalb, which focuses on mastering object-oriented programming (OOP) through building games and graphical user interfaces (GUIs). It includes a detailed table of contents outlining various chapters that cover procedural Python examples, modeling physical objects, managing multiple objects, and using OOP in game development. Additionally, it offers links to download the book and other related ebooks from the website ebookmeta.com.

Uploaded by

kobaeprofir30
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Object-Oriented Python 1st Edition Irv Kalb pdf

download

https://ebookmeta.com/product/object-oriented-python-1st-edition-
irv-kalb/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Object-Oriented Python 1st Edition Irv Kalb

https://ebookmeta.com/product/object-oriented-python-1st-edition-
irv-kalb/

Object-Oriented Python: Master OOP by Building Games


and GUIs 1st Edition Irv Kalb

https://ebookmeta.com/product/object-oriented-python-master-oop-
by-building-games-and-guis-1st-edition-irv-kalb/

Python 3 Object oriented Programming Building robust


and maintainable software with object oriented design
patterns in Python 2nd Edition Phillips

https://ebookmeta.com/product/python-3-object-oriented-
programming-building-robust-and-maintainable-software-with-
object-oriented-design-patterns-in-python-2nd-edition-phillips/

The World Series Allan Morey

https://ebookmeta.com/product/the-world-series-allan-morey/
Monkey King Volume 11 Fight to the Death 1st Edition
Wei Dong Chen Chao Peng

https://ebookmeta.com/product/monkey-king-volume-11-fight-to-the-
death-1st-edition-wei-dong-chen-chao-peng/

Tribe Master 3 A Fantasy Harem Adventure 1st Edition


Noah Layton

https://ebookmeta.com/product/tribe-master-3-a-fantasy-harem-
adventure-1st-edition-noah-layton/

Delivering on the Promise of Democracy Visual Case


Studies in Educational Equity and Transformation 1st
Edition Sukhwant Jhaj

https://ebookmeta.com/product/delivering-on-the-promise-of-
democracy-visual-case-studies-in-educational-equity-and-
transformation-1st-edition-sukhwant-jhaj/

Introducing Translation Studies Theories and


Applications 5th Edition Jeremy Munday

https://ebookmeta.com/product/introducing-translation-studies-
theories-and-applications-5th-edition-jeremy-munday/

Framing the Sexual Subject The Politics of Gender


Sexuality and Power Richard Parker (Editor)

https://ebookmeta.com/product/framing-the-sexual-subject-the-
politics-of-gender-sexuality-and-power-richard-parker-editor/
Global Politics A New Introduction 3rd Edition Jenny
Edkins Editor Maja Zehfuss Editor

https://ebookmeta.com/product/global-politics-a-new-
introduction-3rd-edition-jenny-edkins-editor-maja-zehfuss-editor/
CONTENTS IN DETAIL

TITLE PAGE

COPYRIGHT

DEDICATION

ABOUT THE AUTHOR

ACKNOWLEDGMENTS

INTRODUCTION
Who Is This Book For?
Python Version(s) and Installation
How Will I Explain OOP?
What’s in the Book
Development Environments
Widgets and Example Games

PART I: INTRODUCING OBJECT-ORIENTED


PROGRAMMING

CHAPTER 1: PROCEDURAL PYTHON EXAMPLES


Higher or Lower Card Game
Representing the Data
Implementation
Reusable Code
Bank Account Simulations
Analysis of Required Operations and Data
Implementation 1—Single Account Without Functions
Implementation 2—Single Account with Functions
Implementation 3—Two Accounts
Implementation 4—Multiple Accounts Using Lists
Implementation 5—List of Account Dictionaries
Common Problems with Procedural Implementation
Object-Oriented Solution—First Look at a Class
Summary

CHAPTER 2: MODELING PHYSICAL OBJECTS WITH OBJECT-


ORIENTED PROGRAMMING
Building Software Models of Physical Objects
State and Behavior: Light Switch Example
Classes, Objects, and Instantiation
Writing a Class in Python
Scope and Instance Variables
Differences Between Functions and Methods
Creating an Object from a Class
Calling Methods of an Object
Creating Multiple Instances from the Same Class
Python Data Types Are Implemented as Classes
Definition of an Object
Building a Slightly More Complicated Class
Representing a More Complicated Physical Object as a Class
Passing Arguments to a Method
Multiple Instances
Initialization Parameters
Classes in Use
OOP as a Solution
Summary

CHAPTER 3: MENTAL MODELS OF OBJECTS AND THE


MEANING OF “SELF”
Revisiting the DimmerSwitch Class
High-Level Mental Model #1
A Deeper Mental Model #2
What Is the Meaning of “self”?
Summary

CHAPTER 4: MANAGING MULTIPLE OBJECTS


Bank Account Class
Importing Class Code
Creating Some Test Code
Creating Multiple Accounts
Multiple Account Objects in a List
Multiple Objects with Unique Identifiers
Building an Interactive Menu
Creating an Object Manager Object
Building the Object Manager Object
Main Code That Creates an Object Manager Object
Better Error Handling with Exceptions
try and except
The raise Statement and Custom Exceptions
Using Exceptions in Our Bank Program
Account Class with Exceptions
Optimized Bank Class
Main Code That Handles Exceptions
Calling the Same Method on a List of Objects
Interface vs. Implementation
Summary

PART II: GRAPHICAL USER INTERFACES WITH


PYGAME

CHAPTER 5: INTRODUCTION TO PYGAME


Installing Pygame
Window Details
The Window Coordinate System
Pixel Colors
Event-Driven Programs
Using Pygame
Bringing Up a Blank Window
Drawing an Image
Detecting a Mouse Click
Handling the Keyboard
Creating a Location-Based Animation
Using Pygame rects
Playing Sounds
Playing Sound Effects
Playing Background Music
Drawing Shapes
Reference for Primitive Shapes
Summary

CHAPTER 6: OBJECT-ORIENTED PYGAME


Building the Screensaver Ball with OOP Pygame
Creating a Ball Class
Using the Ball Class
Creating Many Ball Objects
Creating Many, Many Ball Objects
Building a Reusable Object-Oriented Button
Building a Button Class
Main Code Using a SimpleButton
Creating a Program with Multiple Buttons
Building a Reusable Object-Oriented Text Display
Steps to Display Text
Creating a SimpleText Class
Demo Ball with SimpleText and SimpleButton
Interface vs. Implementation
Callbacks
Creating a Callback
Using a Callback with SimpleButton
Summary

CHAPTER 7: PYGAME GUI WIDGETS


Passing Arguments into a Function or Method
Positional and Keyword Parameters
Additional Notes on Keyword Parameters
Using None as a Default Value
Choosing Keywords and Default Values
Default Values in GUI Widgets
The pygwidgets Package
Setting Up
Overall Design Approach
Adding an Image
Adding Buttons, Checkboxes, and Radio Buttons
Text Output and Input
Other pygwidgets Classes
pygwidgets Example Program
The Importance of a Consistent API
Summary

PART III: ENCAPSULATION, POLYMORPHISM, AND


INHERITANCE

CHAPTER 8: ENCAPSULATION
Encapsulation with Functions
Encapsulation with Objects
Objects Own Their Data
Interpretations of Encapsulation
Direct Access and Why You Should Avoid It
Strict Interpretation with Getters and Setters
Safe Direct Access
Making Instance Variables More Private
Implicitly Private
More Explicitly Private
Decorators and @property
Encapsulation in pygwidgets Classes
A Story from the Real World
Abstraction
Summary

CHAPTER 9: POLYMORPHISM
Sending Messages to Real-World Objects
A Classic Example of Polymorphism in Programming
Example Using Pygame Shapes
The Square Shape Class
The Circle and Triangle Shape Classes
The Main Program Creating Shapes
Extending a Pattern
pygwidgets Exhibits Polymorphism
Polymorphism for Operators
Magic Methods
Comparison Operator Magic Methods
A Rectangle Class with Magic Methods
Main Program Using Magic Methods
Math Operator Magic Methods
Vector Example
Creating a String Representation of Values in an Object
A Fraction Class with Magic Methods
Summary

CHAPTER 10: INHERITANCE


Inheritance in Object-Oriented Programming
Implementing Inheritance
Employee and Manager Example
Base Class: Employee
Subclass: Manager
Test Code
The Client’s View of a Subclass
Real-World Examples of Inheritance
InputNumber
DisplayMoney
Example Usage
Multiple Classes Inheriting from the Same Base Class
Abstract Classes and Methods
How pygwidgets Uses Inheritance
Class Hierarchy
The Difficulty of Programming with Inheritance
Summary

CHAPTER 11: MANAGING MEMORY USED BY OBJECTS


Object Lifetime
Reference Count
Garbage Collection
Class Variables
Class Variable Constants
Class Variables for Counting
Putting It All Together: Balloon Sample Program
Module of Constants
Main Program Code
Balloon Manager
Balloon Class and Objects
Managing Memory: Slots
Summary

PART IV: USING OOP IN GAME DEVELOPMENT

CHAPTER 12: CARD GAMES


The Card Class
The Deck Class
The Higher or Lower Game
Main Program
Game Object
Testing with __name__
Other Card Games
Blackjack Deck
Games with Unusual Card Decks
Summary

CHAPTER 13: TIMERS


Timer Demonstration Program
Three Approaches for Implementing Timers
Counting Frames
Timer Event
Building a Timer by Calculating Elapsed Time
Installing pyghelpers
The Timer Class
Displaying Time
CountUpTimer
CountDownTimer
Summary

CHAPTER 14: ANIMATION


Building Animation Classes
SimpleAnimation Class
SimpleSpriteSheetAnimation Class
Merging Two Classes
Animation Classes in pygwidgets
Animation Class
SpriteSheetAnimation Class
Common Base Class: PygAnimation
Example Animation Program
Summary

CHAPTER 15: SCENES


The State Machine Approach
A pygame Example with a State Machine
A Scene Manager for Managing Many Scenes
A Demo Program Using a Scene Manager
The Main Program
Building the Scenes
A Typical Scene
Rock, Paper, Scissors Using Scenes
Communication Between Scenes
Requesting Information from a Target Scene
Sending Information to a Target Scene
Sending Information to All Scenes
Testing Communications Among Scenes
Implementation of the Scene Manager
run() Method
Main Methods
Communication Between Scenes
Summary

CHAPTER 16: FULL GAME: DODGER


Modal Dialogs
Yes/No and Alert Dialogs
Answer Dialogs
Building a Full Game: Dodger
Game Overview
Implementation
Extensions to the Game
Summary

CHAPTER 17: DESIGN PATTERNS AND WRAP-UP


Model View Controller
File Display Example
Statistical Display Example
Advantages of the MVC Pattern
Wrap-Up

INDEX
OBJECT-ORIENTED PYTHON

Master OOP by Building Games and GUIs

by Irv Kalb
Object-Oriented Python. Copyright © 2022 by Irv Kalb.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information storage or
retrieval system, without the prior written permission of the copyright owner and the publisher.
First printing
25 24 23 22 21 1 2 3 4 5 6 7 8 9
ISBN-13: 978-1-7185-0206-2 (print)
ISBN-13: 978-1-7185-0207-9 (ebook)
Publisher: William Pollock
Managing Editor: Jill Franklin
Production Manager: Rachel Monaghan
Production Editor: Kate Kaminski
Developmental Editor: Liz Chadwick
Cover Illustrator: James L. Barry
Interior Design: Octopod Studios
Technical Reviewer: Monte Davidoff
Copyeditor: Rachel Head
Compositor: Maureen Forys, Happenstance Type-O-Rama
Proofreader: Paula L. Fleming
Indexer: Valerie Haynes Perry
The following images are reproduced with permission:
Figure 2-1, photo by David Benbennick, printed under the Creative Commons Attribution-Share
Alike 3.0 Unported license, https://creativecommons.org/licenses/by-sa/3.0/deed.en.
For information on book distributors or translations, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900; info@nostarch.com
www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Names: Kalb, Irv, author.
Title: Object-oriented Python: master OOP by building games and GUIs / Irv Kalb.
Description: San Francisco : No Starch Press, [2021] | Includes index. |
Identifiers: LCCN 2021044174 (print) | LCCN 2021044175 (ebook) | ISBN
9781718502062 (print) | ISBN 9781718502079 (ebook)
Subjects: LCSH: Object-oriented programming (Computer science) | Python
(Computer program language)
Classification: LCC QA76.64 .K3563 2021 (print) | LCC QA76.64 (ebook) |
DDC 005.1/17--dc23
LC record available at https://lccn.loc.gov/2021044174
LC ebook record available at https://lccn.loc.gov/2021044175
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc.
Other product and company names mentioned herein may be the trademarks of their respective
owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The information in this book is distributed on an “As Is” basis, without warranty. While every
precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc.
shall have any liability to any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in it.
Other documents randomly have
different content
The paternal authority of the archaic type here considered formed
only a transitional stage in the history of human institutions. It
declined gradually, according as the religious basis on which it rested
became more unstable. The introduction of a new religion with
higher conceptions of human rights particularly contributed to its
fall. Paying special attention to its influence on the laws of marriage,
I shall endeavour to trace the main features of this highly important
process, which released children from paternal despotism.
Among the Hebrews, a modification of the patriarchal principle
took place as early as the seventh century before the Christian
era;1455 and, according to the Talmudic law, a marriage, to be valid,
must be contracted with the voluntary consent of both the parties
concerned.1456 In Arabia, Mohammed limited the paternal
power.1457 According to all the Mohammedan schools, a son is at
liberty to contract a marriage without his father’s consent, after he
has completed his fifteenth year. The Hanafîs and Shiahs grant the
same privilege to a daughter, whereas, according to other schools, a
woman is emancipated from paternal control only through
marriage.1458 A Mohammedan father certainly has the right to
impose the status of marriage on his children during their minority,
sons and daughters alike, but the law takes particular care that this
right shall never be exercised to the prejudice of the infant. Any act
of the father which is likely to injure the interest of the minor is
considered illegal, and entitles the judge to interfere in order to
prevent the completion of such act, or, if complete, to annul it.1459
In the mature Greek jurisprudence the paternal power was more
restricted than during the Homeric age;1460 and the Roman patria
potestas gradually became a shadow of what it had been. Under the
Republic the abuses of paternal authority were checked by the
censors, and in later times the Emperors reduced the father’s power
within comparatively narrow limits. Alexander Severus ordained that
severe punishments should be inflicted on members of a family only
by the magistrate. Diocletian and Maximilian took away the power of
selling freeborn children as slaves; and Constantine declared the
father who killed his child guilty of murder.1461 The father’s privilege
of dictating marriage for his sons declined into a conditional
veto;1462 and it seems as if daughters also, at length, gained a
certain amount of freedom in the choice of a husband. At any rate, a
daughter could protest, if the father wished to give her in marriage
to a man with a bad reputation.1463
“La philosophie stoïcienne et le christianisme,” says M.
Koenigswarter, “qui hâtèrent le développement des principes
d’égalité, furent surtout favorables aux fils de famille et aux
femmes.”1464 The influence of Christianity shows itself in Teutonic
legislation as well as in Roman. An edict of Clothaire I. in 560
prohibited the forcing of women to marry against their will;1465
although a Council held at Paris three years earlier expressly
required the consent of the parents also.1466 According to the laws
of Cnut, no woman or girl could be forced to marry a man whom she
disliked.1467 The Swedish ‘Westgöta-lag’ permitted a woman to
dissolve a marriage which had been contracted without her
consent;1468 and similar privileges were granted to her in the
‘Uplands-lag’1469 and certain other Teutonic law-books.1470 Later on,
the ‘Schwabenspiegel’—a faithful echo of canonical ideas—says,
“When a young man has completed his fourteenth year, he can take
a wife without the consent of his father.... At twelve years, a maiden
is marriageable; and the marriage subsists, even if contracted in
spite of her father, or other relatives.”1471 A similar privilege, during
the Middle Ages, was granted to German women in general.1472 But
the feelings of the people seemed to have been opposed to it, and
required the consent of the parents. Thus Ulrich von Lichtenstein
says in his ‘Frauenbuch,’ “A girl who has no parents should follow the
advice of her kinsfolk; if she gives herself to a man of her own
accord, she may live with shame.”1473
Paternal authority has declined more rapidly in some countries
than in others. The process has been especially slow in France. In
the literature of the eleventh century, says M. Bernard, the paternal
character is “everywhere honoured, and filial piety everywhere
praised and rewarded. In the romances of chivalry fathers are never
ridiculous; nor sons insolent and mocking.... Above the majesty of
the feudal baron, that of the paternal power was held still more
sacred and inviolable. However powerful the son might be, he would
not have dared to outrage his father, whose authority was in his eyes
always confounded with the sovereignty of command.”1474 This
respect exercised a tyrannical dominion for centuries. Du Vair
remarks, “Nous devons tenir nos pères comme des dieux en
terre.”1475 Bodin wrote, in the later part of the sixteenth century,
that, though the monarch commands his subjects, the master his
disciples, the captain his soldiers, there is none to whom nature has
given any command except the father, “who is the true image of the
great sovereign God, universal father of all things.”1476 In the Duke
of Sully’s ‘Memoirs’ we read that, in his days in France, children were
not permitted to sit in the presence of their parents without being
commanded to do so.1477 According to the edicts of Henry III.
(1566), Louis XIII. (1639), and Louis XIV. (1697), sons could not
marry before the age of thirty, nor daughters before that of twenty-
five, without the consent of the father and mother, on pain of being
disinherited.1478 Speaking of the women among the nobility and
upper classes in France during the eighteenth century, Messrs. de
Goncourt remark, “Généralement le mariage de la jeune fille se
faisait presque immédiatement au sortir du couvent, avec un mari
accepté et agréé par la famille. Car le mariage était avant tout une
affaire de famille, un arrangement au gré des parents, qui décidaient
des considérations de position et d’argent, des convenances de rang
et de fortune. Le choix était fait d’avance pour la jeune personne,
qui n’était pas consultée.”1479
Even now French law accords considerable power to parents. A
child cannot quit the paternal residence without the permission of
the father before the age of twenty-one except for enrolment in the
army.1480 For grave misconduct by his children the father has strong
means of correction.1481 A son under twenty-five and a daughter
under twenty-one cannot marry without the consent of their
parents;1482 and, even when a man has attained his twenty-fifth
year, and the woman her twenty-first, both are still bound to ask for
it, by a formal notification.1483 Parental restraints upon marriage
exist to a very great extent in Germany and Holland also, the
marriage of minors being absolutely void, if effected without the
consent of the father, or of the mother if she be the survivor.
According to American, Scotch, and Irish law, on the other hand, the
consent of parents and guardians to the marriage of minors is not
requisite to the validity of the union. The same was the case in
England prior to the statute of 26 Geo. II. c. 33, which declared all
marriages by license, when either of the parties was under the age
of twenty-one years, if celebrated without publication of banns, or
without the consent of the father or unmarried mother, or guardian
to be absolutely null and void.1484
There is thus a certain resemblance between the family institution
of savage tribes and that of the most advanced races. Among both,
the grown-up son, and frequently the grown-up daughter, enjoys a
liberty unknown among peoples at an intermediate stage of
civilization. There are, however, these vital differences:—that
children in civilized countries are in no respect the property of their
parents; that they are born with certain rights guaranteed to them
by society; that the birth of children gives parents no rights over
them other than those which conduce to the children’s happiness.
These ideas, essential as they are to true civilization, are not many
centuries old. It is a purely modern conception the French
Encyclopedist expresses when he says, “Le pouvoir paternel est
plutôt un devoir qu’un pouvoir.”1485
CHAPTER XI
SEXUAL SELECTION AMONG ANIMALS

The expression, “Sexual Selection,” was first used by Mr. Darwin.


Besides natural selection, which depends on the success of both
sexes, at all ages, in relation to the general conditions of life, he
introduced another principle, sexual selection, which depends on the
success of certain individuals over others of the same sex, in relation
to the propagation of the species. According to the former principle,
those individuals who are most successful in the struggle for
existence survive the others, and characters useful to the species are
thus inherited; according to the latter, those individuals who have
the greatest success in the struggle for mates have the most
numerous offspring, and the characters which gave them the
preference pass on to the new generation, and are afterwards
intensified by the operation of like causes. The sexual struggle is of
two kinds. In both it is carried on by individuals of the same sex; but
in one these individuals, generally the males, try to drive away or kill
their rivals; in the other, they seek to excite or charm those of the
opposite sex, generally the females, who select the most attractive
males for their partners. Therefore, the characters acquired through
sexual selection, and transmitted chiefly to offspring of the same
sex, generally the males, are, on the one hand, weapons for battle,
vigour and courage; on the other hand, certain colours, forms,
ornaments, sounds, or odours, which are felt to be pleasant. The
secondary sexual characters of the latter sort are thus due to the
taste of the females. They have been acquired because they are
beautiful or otherwise agreeable, whereas the characters resulting
from natural selection have been acquired because they are useful.
How are we to explain the origin of this wonderful æsthetic faculty?
“The senses of man and of the lower animals,” says Mr. Darwin,
“seem to be so constituted that brilliant colours and certain forms,
as well as harmonious and rhythmical sounds, give pleasure and are
called beautiful; but why this should be so we know not.”1486
According to Mr. Darwin, natural and sexual selection are two
different sources from which animal characters have arisen. There is
some truth in the statement of one of his critics, “Mr. Darwin, in fact,
has so far abandoned his former belief in the efficacy of ‘natural
selection’ as an agent in producing the differences which separate
different species of animals, as to admit that some supplementary
cause must, in some cases at any rate, be looked for; and this he
thinks is to be found in the action, through long periods, of ‘sexual
selection.’”1487
Far from co-operating with the process of natural selection, sexual
selection, as described by Mr. Darwin, produces effects
disadvantageous to the species. “It is evident,” he says, “that the
brilliant colours, top-knots, fine plumes, &c., of many male birds
cannot have been acquired as a protection; indeed, they sometimes
lead to danger.”1488 When we consider what an important part is
played by colours, as means of protection, in the whole animal
kingdom, it is certainly surprising that many male animals display
brilliant hues, which cannot fail to make them conspicuous to their
enemies. The strong odours emitted by certain reptiles and
mammals, during the pairing season, and the sounds produced by
various species at the same period, have also the effect of attracting
hostile animals that are searching for food. And the danger arising
for the species from these secondary sexual characters is all the
greater because they generally appear at the time when offspring is
about to be produced. Thus, besides colours, structures, and
functions, adapted in the most marvellous way to the requirements
of each species, there are others highly dangerous, which, according
to Mr. Darwin, depend upon an æsthetic sense, the origin of which
we do not know, and which is absolutely useless.
Mr. Darwin, in his many works, has shown how immense is the
influence exercised by natural selection on the organic world. A
disciple, therefore, naturally feels perplexed when he is told of a
series of facts, which, according to the explanation given by the
master, are opposed to natural selection. When the contradiction
between the theories of natural and sexual selection is distinctly
realized, the question arises:—Can we be sure that the secondary
sexual characters are so useless as Mr. Darwin suggests? May not
they also be explained by the principle of the survival of the fittest?
The larger size and greater strength of the males, and the weapons
of offence or defence many of them possess, may easily be so
accounted for, as, among the higher animals, the males generally
fight with each other for the possession of the females. The point is
whether the other secondary sexual characters can be due to the
same cause.

It is an established fact that the colours of flowers serve a definite


end. Through them the flowers are recognized by insects in search
of honey; and the insects, during their visits, involuntarily carry the
pollen of one flower to the stigma of another, and thus effect cross-
fertilization, which is proved to be of great importance for the vigour
and fertility of the next generation of plants. Now it is extremely
interesting to note that brilliant colours are found only in species of
flowers to which they are useful as means of attracting insects; they
never occur in plants which are fertilized by the wind.1489 Mr.
Wallace observes that plants rarely need to be concealed, because
they obtain protection by their spines, or their hardness, or their
hairy covering, or their poisonous secretions. Hence there are very
few cases of what seems to be true protective colouring among
them.1490 In animals, on the contrary, colour is greatly influenced by
their need of protection from, or warning to, their numerous
enemies; colours of other kinds must always, to a certain extent, be
dangerous for the species. Is it probable, then, that, whilst gay
colours occur only in the flowers of those plants to which they are of
real use, conspicuous colours should occur in animals to which they
are of real danger—merely because the females find them beautiful?
Mr. Wallace, whose well-known criticism of Mr. Darwin’s theory of
sexual selection1491 seems, in many points, to be conclusive,
suggests that the very frequent superiority of the male bird or insect
in brightness or intensity of colour is due to the greater vigour and
activity and the higher vitality of the male. This intensity of
coloration is therefore most manifest in the male during the breeding
season, when the vitality is at a maximum. It would be further
developed by the combats of the males for the possession of the
females; and the most vigorous and energetic usually leaving the
most numerous and most healthy offspring, natural selection would
indirectly become a preserver and intensifier of colour.1492 Mr.
Wallace has made it very probable that there is some connection
between vigour and colour, but another question is whether this
connection, depending on some unknown physiological law, is so
necessary that it takes place even when colour is positively
disadvantageous to the species. Nothing of the kind is found in the
vegetable kingdom. We know, as Mr. Wallace himself remarks, that
colours which rarely or never appear in the species in a state of
nature, continually occur among cultivated plants and domesticated
animals—a fact which shows that the capacity to develop colour is
ever present.1493 Among wild plants such colour variations are never
preserved except when they are useful. Is it not most reasonable to
suppose that the like is the case with animals?
The truth seems to be that colour subserves the same purpose in
both of the great kingdoms of the organic world. Just as flowers are
coloured that insects may recognize where honey is to be found, and
thus may be led to promote fertilization, so the sexual colours of
animals have been developed to make it easier for the sexes to find
each other during the pairing time. Protective colours are useful so
far as they conceal the animal from its enemies, but, at the same
time, they conceal it from individuals of its own species. Sexual
colours are therefore useful as well, because they make the animal
more visible. It is quite in accordance with the theory of natural
selection that, where such colours occur, the advantage from them
should be greater than the disadvantage. We can see the reason for
the brilliant colours of humming-birds, as these birds, on account of
their great activity “are practically unmolested,”1494 and for the
bright hues of the rose chafers, who are saved from attack by a
combination of protecting characters.1495 But generally there is
danger in sexual colours, so that nature has given them with the
utmost cautiousness. Usually they occur in males only, because of
the females’ greater need of protection.1496 They are not developed
till the age of reproduction, and they appear, in a great many
species, only during the pairing season. The greatest advantage is
won with the least possible peril.
It is a fact of great importance that sexual colours occur exactly in
those species whose habits make these colours most visible. Thus
the nocturnal moths, taken as a body, are much less gaily decorated
than butterflies, all of which are diurnal in their habits, although,
according to Mr. Wallace, the general influence of solar light and
heat is no adequate cause for the variety, intensity, and complexity
of the colours. The females of the ghost moth are yellow with darker
markings, whereas the males are white, that they may be more
easily seen by the females whilst flying about in the dusk; and it is
remarkable that, in the Shetland Islands, the male of this moth,
instead of differing widely from the female, frequently resembles her
closely in colour,—as Mr. Fraser suggests,1497 because, at the season
of the year when the ghost moth appears in these northern
latitudes, the whiteness of the males is not needed to render them
visible to the females in the twilight night. Both Mr. Darwin1498 and
Mr. Wallace1499 think that, in this case, colour may be a means of
recognition. Sexual colours occur chiefly in species which, because of
their manner of living, are to be seen at a distance; they seldom
occur in sedentary or slowly moving terrestrial animals.1500 The
members of the lowly organized order Thysanura are wingless and
dull-coloured. The Hemiptera, which usually lurk about plants, and
prey upon hapless insects, are not, as a rule, remarkable for
conspicuous hues. The Orthoptera are all terrestrial in their habits,
generally feeding upon plants, and, although some exotic locusts are
beautifully ornamented, their bright tints, according to Mr. Darwin,
do not seem to fall under the head of sexual coloration. On the other
hand, the dragon-flies, which live in the open air, possess splendid
green, blue, yellow, and vermilion metallic tints, and the sexes often
differ in their coloration. Every one has admired the extreme beauty
of many butterflies, especially of the males. Amongst the Fishes,
living in a medium through which bright colours may be observed at
a distance, we often find, besides protective colours, conspicuous
hues which are especially intense and visible during the pairing time.
Among the Reptiles, the little lizards of the genus Draco especially
deserve attention; they glide through the air on their rib-supported
parachutes, and the beauty of their colours baffles description.
Mammals, on the other hand, do not generally present the splendid
tints so common among male birds; and the brighter colours of
certain arboreal mammals serve chiefly as means of concealment.
These phenomena seem to show that sexual colours have been
evolved for the purpose of being seen. They can scarcely be due
merely to the fact that coloration is connected with the degree of
vitality, since the Mammals, for instance, are certainly not less
vigorous than any of the other Vertebrate orders. It may perhaps be
suggested that, as flying animals more easily escape their enemies
than terrestrial, they may with less danger be decorated with
conspicuous hues. But here we have to observe the most important
fact, that animals which do not possess sexual colours generally
have some other means of making themselves discoverable.
Flowers which need the help of insects for fertilization attract
them, in some cases, not by bright colours, but by peculiar odours.
And as we do not find conspicuous colours in plants fertilized by the
wind, so flowers have no perfume except where it is of real use. The
most brilliant flowers, as a rule, are those which possess least odour,
whilst many of them have no scent at all. White or very pale flowers
are generally the most odoriferous. M. Mongredien gives a list of
about 160 species of hardy trees and shrubs with showy flowers,
and another list of sixty species with fragrant flowers; but only
twenty of the latter are included among the showy species, and
these are almost all white-flowered.1501 Most of the white flowers
are scented only at night, or their perfumes are most powerfully
emitted at that time; the reason being that white flowers are
fertilized chiefly by night-flying insects. We arrive thus at two
conclusions: first, that powerful odours and conspicuous colours as
guides to insect fertilizers are, as a rule, complementary to each
other; secondly, that they occur alternately in the way most useful to
the species.
In the animal kingdom various odours and sounds are closely
connected with the reproduction of the species. During the season of
love a musky odour is emitted by the submaxillary glands of the
crocodile, and pervades its haunts. At the same period the anal
scent-glands of snakes are in active function, and so are the
corresponding glands of the lizards. Many mammals are odoriferous.
In some cases the odour appears to serve as a defence or a
protection, but in other species the glands are confined to the males,
and almost always become more active during the rutting season.
Again, a great many insects have the power of producing stridulous
sounds. In two families of the Homoptera and in three of the
Orthoptera, the males alone possess organs of sound in an efficient
state, and these are used incessantly during the pairing season.
Some male fishes have sound-producing instruments, and the
fishermen of Rochelle assert that the males alone make the noise
during the spawning-time. Of frogs and toads the males emit various
sounds at the pairing time, as in the case of the croaking of our
common frog. During the rutting season, and at no other time, the
male of the huge tortoise of the Galapagos Islands utters a hoarse
bellowing noise, which can be heard at a distance of more than a
hundred yards. Professor Aughey states that on two occasions, being
himself unseen, he watched from a little distance a rattle-snake
coiled up with head erect, which continued to rattle at short intervals
for half an hour; at last he saw another snake approach, and when
they met they paired. Among Birds the power of song, or of giving
forth strange cries, or even instrumental music, is exceedingly
common, particularly in the males during the pairing season; and
almost all male mammals use their voices much more during that
period than at any other time. Some, as the giraffe and porcupine,
are stated to be completely mute except during the rutting season.
The colours, odours, and sounds of animals, like the colours and
odours of plants—so far as they may be assumed to be in some way
connected with the reproductive functions—are, as a rule,
complementary to each other. Stridulating insects are generally not
conspicuously coloured. Among the Homoptera, there do not seem
to be any well-marked cases of ornamental differences between the
sexes. Among crickets, the Locustidæ, and grasshoppers, some
species are beautifully coloured; but Mr. Darwin says, “It is not
probable that they owe their bright tints to sexual selection.
Conspicuous colours may be of use to these insects by giving notice
that they are unpalatable.” Other species have directly protective
colours. The bright hues of stridulating beetles seem to be of use
chiefly for protective and warning purposes; whereas species
belonging to the orders Neuroptera and Lepidoptera, often
extremely conspicuously coloured, are not remarkable for any
stridulous sounds. Frogs and toads, which have an interesting sexual
character in the musical powers possessed by the males, are
evidently coloured according to the principle of protection, or
sometimes tinted with conspicuous hues in order to be more easily
recognized by their enemies as a nauseous food. Of Reptiles, the
Lacertilia excel mainly in bright tints; the Chelonia, Crocodilia, and
Ophidia, in sounds and odours. Among Birds, in one instance at
least, the male is remarkable for his scent. “During the pairing and
breeding season,” says Mr. Gould, with reference to the Australian
musk-duck, “ ... this bird emits a strong musky odour;” it is not
ornamented with any conspicuous hues.1502 Sexual colours and the
power of song are generally complementary to each other among
Birds. “As a general rule,” Mr. Wood remarks, “it is found that the
most brilliant songsters among the birds are attired in the plainest
garb; and it may safely be predicted of any peculiarly gorgeous bird,
that power, quality and sweetness of voice are in inverse ratio to its
beauty of plumage.”1503 Thus, of the British birds, with the
exception of the bullfinch and goldfinch, the best songsters are
plain-coloured, and the brilliant birds of the tropics are hardly ever
songsters. The wild camel in the desert of Kum-tagh has a reddish,
sandy hue, and the males, “even during the rutting season, utter no
sound, but find their consorts by scent.”1504 The musk-deer, well
known for the intolerable perfume which the males emit at the
pairing time, is also entirely silent.1505
Moreover, as appears from what has just been said, the sexual
colours, the perceptible scents and sounds of animals are
complementary to each other in the way that is best suited to make
the animals easily discoverable. As bright colours would be of no
advantage to flowers fertilized by night-flying insects, so they would
be of comparatively little advantage to animals living among grass
and plants, in woods and bushes; whereas sounds and scents make
the animal recognizable at a considerable distance. We have also
seen that it is among flying and aquatic animals that sexual colours
chiefly occur, whereas terrestrial animals excel in sound and scents.
Thus most of the stridulating insects are terrestrial. Whilst brightly-
coloured lizards, living on trees or running from stone to stone, must
attract attention by the brilliance of their covering, crocodiles
inhabiting rivers and jungles, and frogs crawling among the grass,
allure their mates, the former by emitting musky odours, the latter
by producing loud sounds. The odour of the Australian musk-duck,
which depends for its food and for its preservation from danger upon
its powers of diving rather than upon those of flying, is, as Mr. Gould
observes, often perceptible long before the animal can be seen.1506
Mr. Darwin remarks, as regards birds, “Bright colours and the
power of song seem to replace each other. We can perceive that, if
the plumage did not vary in brightness, or if bright colours were
dangerous to the species, other means would be employed to charm
the females; and melody of voice offers one such means.”1507 But if
we accept Mr. Darwin’s theory of sexual selection, we are compelled
to suppose that that inexplicable æsthetic sense of the females has
been developed in the way most dangerous to the species.
Conspicuous colours are admired by the females of those animals
which, by means of such colours, are most easily discovered by their
enemies, and sounds and odours are appreciated exactly in those
species to which they are most perilous. If, on the contrary, we
accept the explanation that, although sexual colours, odours, and
sounds are in some ways hurtful to the species, they are upon the
whole advantageous, inasmuch as they make it easier for the sexes
to find each other, we have a theory in accordance with all known
facts, as well as with the great principle of natural selection. It may
be objected that it is not the females but the males that are the
seekers, whilst the secondary sexual characters generally occur in
the males only. But we have no reason to think that the females are
entirely passive during the pairing season; and several of the
statements collected by Mr. Darwin directly indicate that females are
attracted by the sounds of their future partners. If Burdach is correct
in saying that the male sex generally possesses more acute senses
than the female,1508 it is obvious that secondary sexual characters
would be of less use to females than to males, as it certainly would
be of greater danger.
In his work on ‘Darwinism,’ Mr. Wallace expresses the opinion that
the various sounds and odours which are peculiar to the male serve
as a call to the female, or as an indication of his presence; and, as
he says, “the production, intensification, and differentiation of these
sounds and odours are clearly within the power of natural
selection.”1509 Mr. Wallace has also shown the immense importance
of colour as a means of recognition. The theory here set forth thus,
in fact, very nearly approaches his views. The only difference is that
the sexual colours have been classified under the head of “colour for
recognition,” though the positive cause by which they have been
produced may be a surplus of vital energy.
We have still to consider certain secondary sexual characters
which, according to Mr. Darwin, must be regarded as ornaments.
With these he classes the great horns which rise from the head,
thorax, and clypeus of many male beetles; the appendages with
which some male fishes and reptiles are provided; the combs,
plumes, crests, and protuberances of many male birds; and various
crests, tufts, and mantles of hair which are found in certain
mammals. But some of these characters may be of use to the males
in their fights for females, or serve as means of recognition. Mr.
Wallace suggests that crests and other erectile feathers may have
been useful in making the bird more formidable in appearance, and
in thus frightening away enemies; while long tail or wing feathers
might serve to distract the aim of a bird of prey.1510 Moreover,
characters of which we cannot yet perceive the use may in the
future be brought under the law of utility, as has been the case in so
many other instances. According to Mr. Wallace, the ornamental
appendages of birds and other animals are due to a surplus of vital
energy, leading to abnormal growths in those parts of the
integument where muscular and nervous action are greatest.1511
And where these “ornaments” are of no positive disadvantage to the
species, certainly no other explanation is needed.
For other arguments which may be advanced against Mr. Darwin’s
theory of sexual selection, reference may be made to Mr. Wallace’s
criticisms in ‘Tropical Nature’ and ‘Darwinism.’ We have sufficient
evidence that females are pleased or excited by the males’ display of
their sexual colours,1512 and are charmed by their songs. But Mr.
Darwin’s theory presupposes, amongst many other things, that
almost all the females of a species, over a wide area and for many
successive generations, prefer exactly the same modification of the
colour, or ornament or sounds.1513 Moreover, if the secondary sexual
characters are due to female choice, how shall we explain the
strange fact that the taste of the females varies so much that there
are scarcely two species in which the standard of perfection is
exactly the same? This difficulty did not escape Mr. Darwin. “It is a
curious fact,” he says, “that in the same class of animals sounds so
different as the drumming of the snipe’s tail, the tapping of the
woodpecker’s beak, the harsh trumpet-like cry of certain waterfowl,
the cooing of the turtle-dove, and the song of the nightingale,
should all be pleasing to the females of the several species.” And
further, “What shall we say about the harsh screams of, for instance,
some kinds of macaws; have these birds as bad taste for musical
sounds as they apparently have for colour, judging by the
inharmonious contrast of their bright yellow and blue plumage?”1514
The theory now suggested accounts fully for this difference in
taste. The immense variability of the secondary sexual characters is
precisely what might be expected, if their object is to make it easier
for the sexes to find and recognize each other. And it is natural that
the females should be pleased by colours, odours, or sounds which,
by the association of ideas, are to them the symbols of the most
exciting period of their lives. On the other hand, we know that
differently coloured races of the same species may be disinclined to
pair together.1515 And here, I think, we may draw an important
conclusion. The great stability of the secondary sexual characters
which we find in wild species, but certainly not in animals under
domestication, seems to be due chiefly to the fact that those males
which most typically represent the peculiarities of their species have
the best chance of finding mates.

The reader may have felt some surprise at this strange jump from
the patria potestas to a discussion of merely zoological facts, which
have nothing to do, directly, with the history of human marriage. But
we have now to deal with the sexual selection of man, and, for the
right understanding of this, it was necessary to show that the sexual
selection of the lower animals is entirely subordinate to the great law
of natural selection. Mr. Darwin discussed the origin of the secondary
sexual characters as a preliminary to the statement of his theory
regarding the origin of man, and of the different races of men. At
the end of the next chapter we shall consider whether this theory
appears to be in accordance with facts or not.
CHAPTER XII
THE SEXUAL SELECTION OF MAN: TYPICAL
BEAUTY

By the “Sexual Selection of Man” is meant the choice made by


men and women as regards relations with the opposite sex. Mr.
Darwin has shown that such selection takes place among the lower
Vertebrata, and, judging from what we know of domesticated
animals, it is much more common in the case of females than in that
of males. The male, indeed, as a rule, seems to be ready to pair with
any female, provided she belongs to his own species.1516 As this
probably depends upon the great strength of his sexual impulse, we
may infer that in primitive times, when man had a definite pairing
season, he displayed a like tendency, and that the sexual instinct, in
proportion as it has become less intense, has become more
discriminating.
Even now woman is more particular in her choice than man,
provided that the union takes place without reference to interest. A
Maori proverb says, “Let a man be ever so good-looking, he will not
be much sought after; but let a woman be ever so plain, men will
still eagerly seek after her.”1517 With regard to the Negroes of
Sogno, Merolla da Sorrento states, “Women would have experience
of their husbands before they married them, in like manner as the
men were to have of them; and in this particular I can aver that they
are commonly much more obstinate or fickle than men, for I have
known many instances in which the men were willing to be married,
while the women held back, and either fled away or made
excuses.”1518 Among the Eastern Central Africans, according to Mr.
Macdonald, many cases are known of slave wives running away from
free husbands, but none of slave husbands running away from free
wives.1519 In the crossings between unequal human races, the
father almost always belongs to the superior race. “In every case,”
says M. de Quatrefages, “and especially in transient amours, woman
refuses to lower herself; man is less delicate.”1520 Thus, cases in
which negresses form unions with the indigenous men of America
are very rare;1521 and Dr. Nott, who wrote in the middle of this
century, never personally met any one who was the offspring of a
negro man and a white woman, because of the extreme rarity of
such half-breeds.1522 In New Zealand it sometimes happens that a
European man marries a Maori woman; but Mr. Kerry Nicholls never
came across an instance where a European woman had married a
Maori man.1523 Even in civilized society men are less particular in
their connections than women of corresponding education, no
doubt, would be, even if the rules of everyday morality were the
same for both sexes.

In this and the following four chapters we shall deal with the
instinctive feelings by which the sexes are guided in the act of
selection. We have already observed that the sexual instinct is
excited by artificial means, such as ornaments, mutilations, &c. Now
we have to consider the intrinsic characters of a human being which
affect the passions of a person of the opposite sex.
Mr. Darwin has shown that, among the lower Vertebrata, the
female commonly gives the preference to “the most vigorous,
defiant, and mettlesome male,”—a taste the origin of which is easily
accounted for by the theory of natural selection. A similar instinctive
appreciation of manly strength and courage is found in women,
especially in the women of savage races. In a song, communicated
by Mr. Schoolcraft, an Indian girl gives the following description of
her ideal:— “My love is tall and graceful as the young pine waving on
the hill—And as swift in his course as the noble stately deer—His
hair is flowing, and dark as the blackbird that floats through the air—
And his eyes, like the eagle’s, both piercing and bright—His heart, it
is fearless and great—And his arm, it is strong in the fight.”1524 A
tale from Madagascar tells of a princess whose beauty fascinated all
men. Many princes fought to obtain possession of her; but she
refused them all, and chose a lover who was young, handsome,
courageous, and strong.1525 The beautiful Atalanta gave herself to
the best runner;1526 and the hero suitors of the Finnish myths had
to undergo difficult trials to prove their courage.1527 “When a Dyak
wants to marry,” says Mr. Bock, “he must show himself a hero before
he can gain favour with his intended.” He has to secure a number of
human heads by killing men of hostile tribes; and the more heads he
cuts off, the greater the pride and admiration with which he is
regarded by his bride.1528 The demands of the Sàkalàva girls of
Madagascar are less cruel. When a young man wishes to obtain a
wife, his qualifications, according to Mr. Sibree, are tested thus:
—“Placed at a certain distance from a clever caster of the spear, he
is bidden to catch between his arm and side every spear thrown by
the man opposite to him. If he displays fear or fails to catch the
spear, he is ignominiously rejected; but if there be no flinching and
the spears are caught, he is at once proclaimed an accepted ‘lover.’”
It is said that a similar custom prevailed among the Bétsiléo, another
Madagascar tribe.1529 Among the Dongolowees, as we are informed
by Dr. Felkin, if two men are suitors for a girl, and there is a difficulty
in deciding between the rivals, the following method is adopted. The
fair lady has a knife tied to each forearm, so fixed that the blade of
the knife projects below the elbow. She then takes up a position on
a log of wood, the young men sitting on either side with their legs
closely pressed against hers. Raising her arms, the girl leans
forward, and slowly presses the knives into the thighs of her would-
be husbands. The suitor who best undergoes this trial of endurance
wins the bride, whose first duty after marriage is to dress the
wounds she has herself inflicted.1530 Speaking of the natives on the
River Darling, Major T. L. Mitchell says that the possession of gins, or
wives, appears to be associated with all their ideas of fighting;
“while, on the other hand, the gins have it in their power on such
occasions to evince that universal characteristic of the fair, a
partiality for the brave. Thus it is, that, after a battle, they do not
always follow their fugitive husbands from the field, but frequently
go over as a matter of course, to the victors.”1531
We may infer that women’s instinctive inclination to strong and
courageous men is due to natural selection in two ways. A strong
man is not only father of strong children, but he is also better able
than a weak man to protect his offspring. The female instinct is
especially well marked at the lower stages of civilization, because
bodily vigour is then of most importance in the struggle for
existence. The same principle explains the attraction which health in
a woman has for men. In civilized society, infirmity and sickliness are
not always a serious hindrance to love, but in a savage state, says
Alexander v. Humboldt, “nothing can induce a man to unite himself
to a deformed woman, or one who is very unhealthy.”1532
The ancient Greeks conceived Eros as an extremely handsome
youth, and Aphrodite was the goddess of beauty as well as of love.
So closely are these two ideas—love and beauty—connected. This
connection is not peculiar to the civilized mind. In Tahiti, Cook saw
several instances where women preferred personal beauty to
interest.1533 The Negroes of the West African Coast, according to Mr.
Winwood Reade, often discuss the beauty of their women;1534 and,
among the cannibal savages of Northern Queensland, described by
Herr Lumholtz, the women take much notice of a man’s face,
especially of the part about the eyes.1535 But, although in every
country, in every race, beauty stimulates passion, the ideas of what
constitutes beauty vary indefinitely. As Hume says, “Beauty is no
quality in things themselves; it exists merely in the mind which
contemplates them; and each mind perceives a different
beauty.”1536

You might also like