how to reuse class deinitions?
sam
python.sam at googlemail.com
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
> "__init__.py". When I have things I want to reuse, I put them in
> files named things like ".../site-packages/sdd/goodidea.py", 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 class_defs.py 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