Does Python really follow its philosophy of "Readability counts"?
Luis Zarrabeitia
kyrie at uh.cu
Thu Jan 22 16:48:07 EST 2009
On Thursday 22 January 2009 08:32:51 am Steven D'Aprano wrote:
> And now I have accidentally broken the spam() method, due to a name clash.
True, that's bad. I wish that were 'fixed'.
> Besides, double-underscore names are a PITA to work with:
Isn't that example the point of having self.__private variables? To make sure
that the Parrot.__private attributes don't clash with the RedParrot.__private
attributes with the same name?
[parrot example follows just for context, but my reply ends here]
> >>> class Parrot(object):
>
> ... __colour = 'blue'
> ... def __str__(self):
> ... return 'A %s parrot' % self.__colour
> ... __repr__ = __str__
> ...
>
> >>> class RedParrot(Parrot): # Just like Parrot, only red.
>
> ... __colour = 'red'
> ...
>
> >>> Parrot()
>
> A blue parrot
>
> >>> RedParrot()
>
> A blue parrot
--
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie
More information about the Python-list
mailing list