How does a method of a subclass become a method of the base class?

Peter J. Holzer hjp-python at hjp.at
Mon Mar 27 08:52:15 EDT 2023


On 2023-03-27 01:53:49 +0200, Jen Kris via Python-list wrote:
> But that brings up a new question.  I can create a class instance with
> x = BinaryConstraint(), but what happens when I have a line like
> "EqualityConstraint(prev, v, Strength.REQUIRED)"?

If that is the whole statement it will create a new object of class
EqualityConstraint and immediately discard it. That may have some useful
side effect (for example the object may add itself to a list of
constraints) but this is not apparent from this line.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20230327/a20af97a/attachment.sig>


More information about the Python-list mailing list