In article <4bac361d$0$8840$c3e8...@news.astraweb.com>, Steven D'Aprano <st...@remove-this-cybersource.com.au> 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 (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan -- http://mail.python.org/mailman/listinfo/python-list