[Tutor] using separate py files for classes

Chris Hare chare at labr.net
Wed Nov 2 14:03:01 CET 2011


Ahhhh…. thanks Hugo!!

Chris Hare
chare at labr.net
http://www.labr.net

On Nov 2, 2011, at 2:14 AM, Hugo Arts wrote:

> 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()"
> 
> Hugo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111102/f5593ede/attachment.html>


More information about the Tutor mailing list