Good practice when writing modules...

Robert Kern robert.kern at gmail.com
Sat Nov 15 18:09:10 EST 2008


Robert Kern wrote:
> r0g wrote:
> 
>> The module I am compiling is kind of a scrapbook of snippets for my own
>> development use, it has no coherent theme and I wouldn't be distributing
>> it or using the whole thing in a production environment anyway, just
>> copying the relevant functions into a new module when needed. I'm
>> thinking having the imports inline might make that process easier when I
>> do need to do it and once copied I can always move them out of the
>> functions declarations.
> 
> This is something of a special case, so I don't think the usual style 
> guides entirely apply. What I would do is keep the imports outside of 
> the functions, but put them before the functions that use them.

Actually, I lie. What I really do is keep a Mercurial repository of all of the 
snippets I use in separate files.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list