Scope and classes

David davidshais at googlemail.com
Tue Aug 18 21:12:39 EDT 2009


On Aug 19, 1:17 am, "Jan Kaliszewski" <z... at chopin.edu.pl> wrote:
> 19-08-2009 o 02:10:58 Jan Kaliszewski <z... at chopin.edu.pl> wrote:
>
> > The only ways to reach Abc's attribute 'message' from that method are:
> > * 'Abc.message'
> > * 'self.__class__.message'
> > * 'self.message' (unless there is an instance attribute 'message' which
> > overrides the class attribute).
>
> And of course getattr(Abc), getattr(self.__class__) etc. :-)
>
> --
> Jan Kaliszewski (zuo) <z... at chopin.edu.pl>

Out of 'Abc.message' and 'self.message', which is the favoured
convention? It would be very easy to accidentally override
'self.messages' with an instance attribute!



More information about the Python-list mailing list