Using an object inside a class

Ethan Furman ethan at stoneleaf.us
Mon Jan 23 15:51:06 EST 2012


Gary Herron wrote:
> If the method does not bind it, then Python will look in the class for 
> foo.  This could work
> 
> class Class1:
>      foo = whatever # Available to all instances
>      def __init__(self):
>            foo.bar.object

              self.foo.bar.object

               ^- needs the self reference or will not work

~Ethan~



More information about the Python-list mailing list