Re: Circular Import

2022-04-12 Thread Chris Angelico
On Wed, 13 Apr 2022 at 03:37, Stefano Ovus wrote: > > found a solution: importing modules instead of classes, ex. > > -- square.py > > import circle > > ... > @classmethod > def from_circle(cls, circle: circle.Circle) -> Square: > ... > return cls(...) Yep! Good solution. Be aware that

Re: Circular Import

2022-04-12 Thread Stefano Ovus
found a solution: importing modules instead of classes, ex. -- square.py import circle ... @classmethod def from_circle(cls, circle: circle.Circle) -> Square: ... return cls(...) -- https://mail.python.org/mailman/listinfo/python-list

Circular Import

2022-04-12 Thread Stefano Ovus
How can I avoid circular imports keeping separated modules ? -- square.py from circle import Cirle class Square: def __init__(self): ... @classmethod def from_circle(cls, circle: Circle) -> Square: ... return cls(...) -- circle.py from square import Square class Circle: def

possible circular import problem with python-3, but not python-2

2010-09-27 Thread Darren Dale
py/h5a.c:5248) File "h5p.pxd", line 23, in init h5py.h5t (h5py/h5t.c:16481) File "h5t.pxd", line 17, in init h5py.h5p (h5py/h5p.c:9297) ImportError: No module named h5t That looks like it might be a circular import problem, but it works fine with python-2.6. I'm at a lo

Re: Circular import problem

2007-07-15 Thread Alex Popescu
On Jul 15, 10:08 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 15 Jul 2007 08:49:54 -0300, Alex Popescu > <[EMAIL PROTECTED]> escribió: > > > > >> > But, I still don't understand how python can access a function in a > >> > file I have NOT included. In this case, to get things to w

Re: Circular import problem

2007-07-15 Thread Gabriel Genellina
En Sun, 15 Jul 2007 08:49:54 -0300, Alex Popescu <[EMAIL PROTECTED]> escribió: >> > But, I still don't understand how python can access a function in a >> > file I have NOT included. In this case, to get things to work, I DO >> > NOT "import MMA.grooves" but later in the module I access a functi

Re: Circular import problem

2007-07-15 Thread Alex Popescu
On Jul 14, 6:27 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 13 Jul 2007 13:24:57 -0300, bvdp <[EMAIL PROTECTED]> escribió: > > > > > > >> Seehttp://effbot.org/zone/import-confusion.htm > >> Try to move the circular references later in the code (maybe inside a > >> function, when it

Re: Circular import problem

2007-07-14 Thread Gabriel Genellina
En Sat, 14 Jul 2007 14:44:05 -0300, bvdp <[EMAIL PROTECTED]> escribió: >> > But, I still don't understand how python can access a function in a >> > file I have NOT included. In this case, to get things to work, I DO >> > NOT "import MMA.grooves" but later in the module I access a function >> > wi

Re: Circular import problem

2007-07-14 Thread greg
bvdp wrote: > before I moved other > imports around I was able to do the following: > > 1. NOT include MMA.gooves, > 2. call the function MMA.grooves.somefunc() > > and have it work. The import doesn't necessarily have to be in the same module where the attribute is used. The first time *any*

Re: Circular import problem

2007-07-14 Thread bvdp
> > But, I still don't understand how python can access a function in a > > file I have NOT included. In this case, to get things to work, I DO > > NOT "import MMA.grooves" but later in the module I access a function > > with "xx=MMA.grooves.somefunc()" and it finds the function, and works > > jus

Re: Circular import problem

2007-07-13 Thread Gabriel Genellina
En Fri, 13 Jul 2007 13:24:57 -0300, bvdp <[EMAIL PROTECTED]> escribió: > >> Seehttp://effbot.org/zone/import-confusion.htm >> Try to move the circular references later in the code (maybe inside a >> function, when it is required), or much better, refactor it so there is >> no >> circularity. >>

Re: Circular import problem

2007-07-13 Thread bvdp
Just as a bit of a followup, I have fixed the problem in my code. I changed the order of some of the imports in some other modules. What I was doing was more guesswork and good luck ... but it works. I really wonder if there is a better way to figure these problems out. Reading a few of the other

Re: Circular import problem

2007-07-13 Thread bvdp
> Seehttp://effbot.org/zone/import-confusion.htm > Try to move the circular references later in the code (maybe inside a > function, when it is required), or much better, refactor it so there is no > circularity. > > -- > Gabriel Genellina Yes, thanks. I'd read that page before posting. Helpful.

Re: Circular import problem

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 23:36:16 -0300, bvdp <[EMAIL PROTECTED]> escribió: > I'm going quite nutty here with an import problem. I've got a fairly > complicated program (about 12,000 lines in 34 modules). I just made > some "improvements" and get the following error: > > bob$ mma > Traceback (most rece

Circular import problem

2007-07-12 Thread bvdp
I'm going quite nutty here with an import problem. I've got a fairly complicated program (about 12,000 lines in 34 modules). I just made some "improvements" and get the following error: bob$ mma Traceback (most recent call last): File "/usr/local/bin/mma", line 55, in import MMA.main Fil

Re: circular import problem

2005-09-09 Thread Terry Reedy
"Learning Python" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > An example in the book I didn't understood well > two modules files recursively import/from each other There are past postings available in the archives (via Google) at least, that lucided discuss circular imports.

circular import problem

2005-09-09 Thread Learning Python
An example in the book I didn't understood well two modules files recursively import/from each other in recur1.py,we have: x=1 import recur2 y=1 in recur2.py, we have from recur1 import x from recur1 import y If we run interactively at python command line, >>> import recur1 it has errors li

Re: circular import Module

2005-06-14 Thread Magnus Lycka
Greg Ewing wrote: > Magnus Lycka wrote: > >> Due to the cycle, you can never use file1 without >> file2 or vice versa. Why do you then want it to be >> two different modules instead of one? > > Perhaps because it would then be too big and > unwieldy to maintain? > > Sometimes there are legitimat

Re: circular import Module

2005-06-13 Thread Greg Ewing
Magnus Lycka wrote: > Due to the cycle, you can never use file1 without > file2 or vice versa. Why do you then want it to be > two different modules instead of one? Perhaps because it would then be too big and unwieldy to maintain? Sometimes there are legitimate reasons for mutually-dependent mod

Re: circular import Module

2005-06-10 Thread Terry Hancock
On Friday 10 June 2005 07:27 am, Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > > I have two modules (file1.py and file2.py) > > Is that ok in python (without any weird implication) if my module > > import each other. I mean in module file1.py there exist command import > > file2 and in module fi

Re: circular import Module

2005-06-10 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > Hello, > > I have two modules (file1.py and file2.py) > Is that ok in python (without any weird implication) if my module > import each other. I mean in module file1.py there exist command import > file2 and in module file2.py there exist command import file1? Even if i

Re: circular import Module

2005-06-08 Thread Greg Ewing
Thomas Guettler wrote: > file1.py: > import file2 > > > file2.py: > # import file1 # Does not work! Actually, that *will* work as long as you don't try to use anything from file1 until it has finished being loaded. What won't work is file2.py: from file1 import somename because som

Re: circular import Module

2005-06-08 Thread Philippe C. Martin
That's the only way out I found with some module import problem using code generated by wxDesigner. Josef Meile wrote: >>>Circular import does not work on module level, but you can >>>import the module in a method: >>> >>>file1.py: >>>import fi

Re: circular import Module

2005-06-08 Thread Josef Meile
>>Circular import does not work on module level, but you can >>import the module in a method: >> >>file1.py: >>import file2 >> >> >> >>file2.py: >># import file1 # Does not work! >>def foo(): >>import file1 # Does wor

Re: circular import Module

2005-06-08 Thread Douglas Soares de Andrade
Hi ! > Circular import does not work on module level, but you can > import the module in a method: > > file1.py: > import file2 > > > > file2.py: > # import file1 # Does not work! > def foo(): > import file1 # Does work Cool idea ! It works on local

Re: circular import Module

2005-06-08 Thread Thomas Guettler
ule file2.py there exist command import file1? > > This is not working in C#. Circular import does not work on module level, but you can import the module in a method: file1.py: import file2 file2.py: # import file1 # Does not work! def foo(): import file1 # Does work HTH, Th

circular import Module

2005-06-08 Thread [EMAIL PROTECTED]
Hello, I have two modules (file1.py and file2.py) Is that ok in python (without any weird implication) if my module import each other. I mean in module file1.py there exist command import file2 and in module file2.py there exist command import file1? This is not working in C#. pujo -- http://m