How to do * and & C-lang. operations in Python?
Heiko Wundram
heikowu at ceosg.de
Thu Sep 20 18:23:19 EDT 2001
On Thursday 20 September 2001 19:00, you wrote:
> On 20 Sep 2001, Toni Gaya wrote:
> > Assignaments are done by 'value', not by 'reference'. Function calls
> > are done by 'reference'. How to do assignaments by reference?. In C
>
> Check Google Groups for the answer.
>
> > Another question:
> >
> > module1:
> > import module2
> >
> > module2:
>
> import module1
This shouldn't work, as cyclic imports can't be resolved at runtime (at least
in my projects it always failed...)!
Just put the import module2 at the end of module1 (when you run/import
module1 from an external program as the first item).
What this does is that all code in module1 has already been parsed when
module2 is imported, which imports back module1, which has already been
parsed, and Python doesn't complain anymore.
If you do any kind of cyclic imports, be sure to check this, as it gives rise
to all kinds of quirky errors that may actually seem like resulting from
somewhere else. And be sure to obey the order!
Code Example:
module1:
<blablabla code>
import module2
module2:
import module1
<blablabla code>
mainprog:
import module1
import module2
<blablabla code>
--
Yours sincerely,
Heiko Wundram
More information about the Python-list
mailing list