Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19285

Re: Using an object inside a class

Date 2012-01-23 12:51 -0800
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: Using an object inside a class
References <CAGz2ECYwdnB2ZoTo-DXHhO1_MzdjWeYB+nxeNJ+xivPa8N-tVA@mail.gmail.com> <4F1DC1BD.4040402@digipen.edu>
Newsgroups comp.lang.python
Message-ID <mailman.4982.1327351525.27778.python-list@python.org> (permalink)

Show all headers | View raw


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~

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Using an object inside a class Ethan Furman <ethan@stoneleaf.us> - 2012-01-23 12:51 -0800

csiph-web