Class Issue`
Calvin Spealman
cspealma at redhat.com
Wed Mar 6 09:15:01 EST 2019
> C++ (a language I have no respect for)
This was uncalled for and inappropriate. Please keep discord civil.
On Wed, Mar 6, 2019 at 7:12 AM Rhodri James <rhodri at kynesim.co.uk> wrote:
> On 05/03/2019 22:39, Milt wrote:
> > The following code gives me unusual results - base on experience with
> C++.
> >
> > class Car:
> > # carColor = None
> > # mileage = None
> >
> > def __init__(self, color = None, miles = None):
> > self.mileage = miles
> > self.carColor = color
> >
> > def print(self):
> > print(f"Color: {self.carColor}")
> > print(f"Mileage: {self.mileage}")
> >
> > myCar = Car('blue', 15000)
> > myCar.print()
> >
> > print()
> >
> > myCar = Car(25000, 'orange')
> > myCar.print()
>
> The behaviour you should expect even from C++ (a language I have no
> respect for) is a compile-time error complaining that you are passing an
> integer to a string parameter and vice versa. Python is a dynamically
> typed language; it doesn't enforce any restrictions on what types of
> object can be bound to any given name. This is occasionally a surprise
> when you're being careless, but it really shouldn't break your
> expectations.
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
CALVIN SPEALMAN
SENIOR QUALITY ENGINEER
cspealma at redhat.com M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
More information about the Python-list
mailing list