From: C. B. on

> In that particular case, replace automatic by implicit, and you got the
> reason why it is not a good idea.
> Maybe in your case the C habits clashes to the python habits.

You're right !

As a C developer, I appreciate to only include <string.h> to deal with
strings, without wondering which other header provides size_t

> Talking about python, if the user needs to know about BBB, then it has
> to import it, perdiod. If the user needs to know about many objects,
> then it has to import them all, explicitly.

Ok. If this is the Python way of coding, that's ok for me. I will stop
now my quest for an automatic import and work like that.

The most interesting solution I have found until now is using
PyImport_AppendInittab() and PyEval_GetGlobals() functions. But this
also brings lots of problems (mainly namespaces and unloading).
Anyway, the time spent to look for a solution was a nice way to learn
Python internals :)

From: Aahz on
In article <4bac361d$0$8840$c3e8da3(a)>,
Steven D'Aprano <steve(a)> wrote:
>On Thu, 25 Mar 2010 18:03:58 -0700, C. B. wrote:
>> from mymodule import AAA
>> from mymodule import BBB
>> a = AAA(BBB()))
>> But, as there is no case where AAA can be used without BBB, I would like
>> to avoid importing BBB in my Python scripts when I already import AAA.
>Since AAA must take an argument of BBB, then give it a default:
># in mymodule
>def AAA(arg=BBB()):
> ...

That would frequently give wrong results unless BBB is explicitly
designed to create immutable instances. I strongly suggest doing the
usual mutable dance:

def AAA(arg=None):
if arg is None:
arg = BBB()
Aahz (aahz(a) <*>

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan