how to reuse class deinitions?

sam python.sam at
Mon Oct 2 01:15:03 CEST 2006

> What I do:
> For each new major version of python, in .../site-packages I make a
> directory "sdd" (my initials).  In it I put an empty file named
> "".  When I have things I want to reuse, I put them in
> files named things like ".../site-packages/sdd/", and
> I get use of them in python programs like:
>      from sdd.goodidea import File
>      ...
>      <code that uses File>
>      ...
> or (actually my current style):
>      from sdd import goodidea
>      ...
>      <code that uses goodidea.File>
>      ...

this is basically what i was trying to do. i just tried it again, with
a file in a folder i appended to the system path, itself
containing the class definition for File. then:

from class_defs import File

works fine.

nice to know i was on the right lines. thanks for the pointer!

More information about the Python-list mailing list