[Tutor] using separate py files for classes

Hugo Arts hugo.yoshi at gmail.com
Wed Nov 2 08:14:11 CET 2011

On Wed, Nov 2, 2011 at 7:29 AM, Chris Hare <chare at labr.net> wrote:
> I would like to put each of my classes in separate files to make it easier
> to edit them and keep the various files as small as possible for editing
> purposes.
> I have come across a couple of problems:
> 1.  I have to use import statements like "from file import class" instead of
> "import file"
> 2.  I have to include all of the import statements for things not found in
> the class file
> Is this normal or am I doing something wrong?
> Thanks!
> Chris Hare

That's exactly how it's supposed to work, actually. One thing though,
you can use "import file" rather than "from file import class." You
then acces the class like "a = file.class()"


More information about the Tutor mailing list