Object-Oriented Python 1st Edition Irv Kalb instant download
Object-Oriented Python 1st Edition Irv Kalb instant download
download
https://ebookmeta.com/product/object-oriented-python-1st-edition-
irv-kalb/
https://ebookmeta.com/product/object-oriented-python-1st-edition-
irv-kalb/
https://ebookmeta.com/product/object-oriented-python-master-oop-
by-building-games-and-guis-1st-edition-irv-kalb/
https://ebookmeta.com/product/python-3-object-oriented-
programming-building-robust-and-maintainable-software-with-
object-oriented-design-patterns-in-python-2nd-edition-phillips/
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/
https://ebookmeta.com/product/tribe-master-3-a-fantasy-harem-
adventure-1st-edition-noah-layton/
https://ebookmeta.com/product/delivering-on-the-promise-of-
democracy-visual-case-studies-in-educational-equity-and-
transformation-1st-edition-sukhwant-jhaj/
https://ebookmeta.com/product/introducing-translation-studies-
theories-and-applications-5th-edition-jeremy-munday/
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
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
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
INDEX
OBJECT-ORIENTED PYTHON
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 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
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