Guide to organizing modules?

B

bukzor

I've been finding at work that I've written a set of functions several
times, sometimes with more or less features or bugs, so I've decided
to take my small, useful functions and put them in some common place.
I've made a module for this, but it is quickly becoming a jumbled mess
of unrelated functions. Also the one class that I've written with
inheritance takes up fully 1/3 of the documentation (compared to 20
other functions). Since this is a large class I'm thinking of moving
it to a separate module, but on the other hand it seems silly to have
a whole module for just a single class. Also I'm worried that if I
wait till later to organize it better, I'll have a lot of code where
I'll need to fix-up the naming conventions.

In summary: are there any good (or official) guidelines for how to
organize and separate python functions and classes into modules?
 
A

alex23

In summary: are there any good (or official) guidelines for how to
organize and separate python functions and classes into modules?

Hey bukzor,

Are you familiar with the concept of packages in Python?

http://docs.python.org/tut/node8.html#SECTION008400000000000000000

That should allow you to keep all of your scriptlets as separate files
while still having the advantage of keeping them in a single namespace
for importing.

(But if you know this already, don't mind me....)
 
B

bukzor

Hey bukzor,

Are you familiar with the concept of packages in Python?

http://docs.python.org/tut/node8.html#SECTION008400000000000000000

That should allow you to keep all of your scriptlets as separate files
while still having the advantage of keeping them in a single namespace
for importing.

(But if you know this already, don't mind me....)

Yes, in the above post I meant to say package where I said module.
Right now all my functions are in the __init__.py script, and I would
consider separating them out into sub-packages, if it had any rhyme or
reason, but right now that escapes me. That's mostly what I'm trying
to ask for.

Thanks,
--Buck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top