Using an object inside a class

Ian Kelly ian.g.kelly at gmail.com
Mon Jan 23 16:21:53 EST 2012


On Mon, Jan 23, 2012 at 1:58 PM, MRAB <python at 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



More information about the Python-list mailing list