Well, I can see how this could get real messy but within defining a GUI there are many elements and so the block of elements such as a wx.notebook for instance I would hope I could place all the code for this in another file and somehow include it into place. This way I can work on layered panels and such in a fresh document rather than travesing through tons of widgets and sizers.
Thanks for your replies -- -- Andrew "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 12 Mar 2008 19:42:44 -0500, Andrew Rekdal wrote: > >> I am working in the class constructor defining elements of an >> application. The problem is the file is getting unmanageble and I am >> wanting to extend the contructor __init__ to another file. >> >> Is it possible to import directly into the contructor the contents of >> another module file? >> >> If so how would this be done? > > > Here's the way you do what you literally asked for: > > class MyClass(object): > def __init__(self, *args): > # Warning: completely untested > execfile('myfile.py') # may need extra arguments? > > but you almost certainly don't want to do that. A better way is by > importing modules, the same as you would for anything else: > > class MyClass(object): > def __init__(self, *args): > from AnotherModule import constructor > constructor(self, *args) > > > But frankly if you find yourself needing to do this because your file is > "too big" and is unmanageable, I think you are in desperate need of > refactoring your code to make if more manageable. Pushing vast amounts of > random code out into other files just increases the complexity: not only > do you have vast amounts of code, but you have large numbers of files to > manage as well. > > > > > -- > Steven > > > -- http://mail.python.org/mailman/listinfo/python-list