Re: Good practice when writing modules...

2008-11-16 Thread bearophileHUGS
John Machin: import foo # used by baz() import bar # used by spam() Why bother with the ()? I code in other language too beside Python, in those languages there are other things (like templates in D language) beside functions, so my comment helps me remember that baz() is a function instead

Re: Good practice when writing modules...

2008-11-16 Thread John Machin
On Nov 16, 6:58 pm, [EMAIL PROTECTED] wrote: John Machin: import foo # used by baz() import bar # used by spam() Why bother with the ()? I code in other language too beside Python, in those languages there are other things (like templates in D language) beside functions, so my

Re: Good practice when writing modules...

2008-11-16 Thread Nick Craig-Wood
r0g [EMAIL PROTECTED] wrote: I'm collecting together a bunch of fairly random useful functions I have written over the years into a module. Generally speaking is it best to a) Import all the other modules these functions depend on into the modules global namespace by putting them at the

Re: Good practice when writing modules...

2008-11-16 Thread Lawrence D'Oliveiro
Scott David Daniels wrote: I would amend this advice by adding that you should (in such cases) put a commented-out import at the top level (so you can look at the top of a module's source and see what other modules it relies upon. That's what your editor's search function is for. --

Good practice when writing modules...

2008-11-15 Thread r0g
I'm collecting together a bunch of fairly random useful functions I have written over the years into a module. Generally speaking is it best to a) Import all the other modules these functions depend on into the modules global namespace by putting them at the top of the module or should I... b)

Re: Good practice when writing modules...

2008-11-15 Thread Arnaud Delobelle
r0g [EMAIL PROTECTED] writes: I'm collecting together a bunch of fairly random useful functions I have written over the years into a module. Generally speaking is it best to a) Import all the other modules these functions depend on into the modules global namespace by putting them at the top

Re: Good practice when writing modules...

2008-11-15 Thread bearophileHUGS
r0g: a) Import all the other modules these functions depend on into the modules global namespace by putting them at the top of the module or should I... b) Include them in each function individually. This is a interesting topic, that requires some care. Generally I suggest you put them at the

Re: Good practice when writing modules...

2008-11-15 Thread r0g
[EMAIL PROTECTED] wrote: r0g: a) Import all the other modules these functions depend on into the modules global namespace by putting them at the top of the module or should I... b) Include them in each function individually. This is a interesting topic, that requires some care. Generally

Re: Good practice when writing modules...

2008-11-15 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: r0g: a) Import all the other modules these functions depend on into the modules global namespace by putting them at the top of the module or should I... b) Include them in each function individually. This is a interesting topic, that requires some care. Generally I

Re: Good practice when writing modules...

2008-11-15 Thread John Machin
On Nov 15, 9:08 pm, [EMAIL PROTECTED] wrote: I also put a comment after each import, with the name of the function/ class it is used into: import foo # used by baz() import bar # used by spam() Why bother with the ()? Why bother at all? Surely this rapidly becomes tedious clutter: import

Re: Good practice when writing modules...

2008-11-15 Thread Robert Kern
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

Re: Good practice when writing modules...

2008-11-15 Thread Robert Kern
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