Guide to organizing modules?

Discussion in 'Python' started by bukzor, Jun 6, 2008.

  1. bukzor

    bukzor Guest

    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?
    bukzor, Jun 6, 2008
    #1
    1. Advertising

  2. bukzor

    alex23 Guest

    On Jun 6, 10:32 am, bukzor <> wrote:
    > 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....)
    alex23, Jun 6, 2008
    #2
    1. Advertising

  3. bukzor

    bukzor Guest

    On Jun 5, 5:58 pm, alex23 <> wrote:
    > On Jun 6, 10:32 am, bukzor <> wrote:
    >
    > > 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....)


    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
    bukzor, Jun 6, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dean

    Organizing apps on a web site

    Dean, Aug 21, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    432
  2. =?Utf-8?B?Q2hhcmxpZSBEaXNvbg==?=

    Organizing pages in subdirectories of main directory

    =?Utf-8?B?Q2hhcmxpZSBEaXNvbg==?=, Feb 8, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    387
    Yan-Hong Huang[MSFT]
    Feb 9, 2004
  3. Eric S. Johansson

    organizing collections of small modules

    Eric S. Johansson, Mar 25, 2007, in forum: Python
    Replies:
    2
    Views:
    237
    Eric S. Johansson
    Mar 26, 2007
  4. Replies:
    4
    Views:
    112
    Robert Klemme
    Jul 30, 2007
  5. Replies:
    5
    Views:
    320
    Peter J. Holzer
    Sep 22, 2006
Loading...

Share This Page