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


Groups > comp.lang.python > #19288

Re: Using an object inside a class

References <CAGz2ECYwdnB2ZoTo-DXHhO1_MzdjWeYB+nxeNJ+xivPa8N-tVA@mail.gmail.com> <CALwzidmECS+aVT+K0d+XiVZRJSF3xBn_KT=RwvO45CSf7jRrpw@mail.gmail.com> <CAGz2ECb5rShT-yoNJt9d-KchJAp=ZmLCxnjGwxeg9Mo_YppbrQ@mail.gmail.com> <4F1DC9EA.7010603@mrabarnett.plus.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-01-23 14:21 -0700
Subject Re: Using an object inside a class
Newsgroups comp.lang.python
Message-ID <mailman.4985.1327353746.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jan 23, 2012 at 1:58 PM, MRAB <python@mrabarnett.plus.com> wrote:
>> Either way would work but the main issue is I can't seem to use foo or
>> foo.bar or foo.bar.object anywhere in __init__ or even before that in
>> the main class area.
>>
> This line:
>
> foo = MyApp(0)
>
> will create a 'MyApp' instance and then bind it to the name 'foo'.
> Until that binding occurs, the name 'foo' doesn't exist.

What MRAB said; also note that there is no need to bind your wx.App
instance to a name at all, because you can retrieve it globally by
calling wx.GetApp().

Cheers,
Ian

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


Thread

Re: Using an object inside a class Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-23 14:21 -0700

csiph-web