[issue16392] [doc] import crashes on circular imports in ext modules

2021-12-13 Thread Stefan Behnel
Stefan Behnel added the comment: Given that PEP-489 has landed in Py3.5, which is already retired and has been for more than a year, I think we can just close this issue as outdated. -- resolution: -> out of date stage: needs patch -> resolved status: open -> closed

[issue16392] [doc] import crashes on circular imports in ext modules

2021-12-13 Thread Irit Katriel
Change by Irit Katriel : -- keywords: +easy title: import crashes on circular imports in ext modules -> [doc] import crashes on circular imports in ext modules versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5 ___ Pyt

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Filipe Laíns
Change by Filipe Laíns : -- pull_requests: +25886 pull_request: https://github.com/python/cpython/pull/27344 ___ Python tracker ___

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 0a8ae8a50a0fea3d39ec49b220a5c7a5b70e36f8 by Filipe Laíns in branch 'main': bpo-44717: improve AttributeError on circular imports of submodules (GH-27338) https://github.com/python/cpython/commit/0a8ae8a50a0fea3d39ec49b220a5c7a5b70e36f8

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Filipe Laíns
Change by Filipe Laíns : -- pull_requests: +25881 pull_request: https://github.com/python/cpython/pull/27338 ___ Python tracker ___

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 3eae8f20d7b6f88d3618b0afc94893165a914022 by Pablo Galindo Salgado in branch 'main': Revert "bpo-44717: improve AttributeError on circular imports of submodules (GH-27299)" (GH-27331) https://github.com/python/cpyt

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- pull_requests: +25874 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/27331 ___ Python tracker ___

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: There is a buildbot failure after merging this PR: https://buildbot.python.org/all/#/builders/464/builds/574 If is not fixed in 24 we will need to revert per our buildbot policy -- resolution: fixed -> status: closed -> open

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Łukasz Langa
Łukasz Langa added the comment: Thanks a lot for your report and patch, Filipe! ✨  ✨ -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-24 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset 8072a1181dd64135f700b44372fbf7bf91e68072 by Filipe Laíns in branch 'main': bpo-44717: improve AttributeError on circular imports of submodules (GH-27299) https://github.com/python/cpython/commit/8072a1181dd64135f700b44372fbf7bf91e68072

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-22 Thread Filipe Laíns
Change by Filipe Laíns : -- keywords: +patch pull_requests: +25842 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27299 ___ Python tracker ___

[issue44717] Improve AttributeError on circular imports of submodules

2021-07-22 Thread Filipe Laíns
on hinting that we cannot access the attribute because the module is partially initialized, we could have something similar here. -- components: Interpreter Core messages: 398021 nosy: FFY00, pablogsal priority: normal severity: normal status: open ti

[issue16392] import crashes on circular imports in ext modules

2020-01-28 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue16392] import crashes on circular imports in ext modules

2015-05-08 Thread Brett Cannon
Brett Cannon added the comment: https://www.python.org/dev/peps/pep-0489/ is trying to come up with a redesign of extension module loading and no one has submitted a patch for the documentation (although Stefan has inlined proposed wording in a comment). --

[issue16392] import crashes on circular imports in ext modules

2015-05-08 Thread R. David Murray
R. David Murray added the comment: Yes, the resolution of this issue will be to add documentation. Someone should turn Stefan's comment into a patch. -- assignee: - docs@python components: +Documentation nosy: +docs@python, r.david.murray stage: - needs patch versions: +Python 3.5

[issue16392] import crashes on circular imports in ext modules

2015-05-08 Thread Omer Katz
Omer Katz added the comment: Is this issue resolved in any way? Has there been a decision made on how to resolve it? What's the status here? -- nosy: +Omer.Katz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392

[issue16392] import crashes on circular imports in ext modules

2013-08-23 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___

[issue16392] import crashes on circular imports in ext modules

2012-11-15 Thread Andrew Svetlov
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___ ___

[issue16392] import crashes on circular imports in ext modules

2012-11-12 Thread Eric Snow
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___ ___ Python-bugs-list

[issue16392] import crashes on circular imports in ext modules

2012-11-08 Thread Brett Cannon
Brett Cannon added the comment: The fully qualified name requirement is definitely a design flaw where init functions should just be given the module object with everything already set, just like what @importlib.util.module_for_loader does. Hopefully we can come up with a solution through

[issue16392] import crashes on circular imports in ext modules

2012-11-07 Thread Stefan Behnel
Stefan Behnel added the comment: Agreed. Since it doesn't really fit into any specific function documentation, I would place it right at the top. Something like this: The following functions can be used by C code to call into Python's import machinery. Note that Python 3 does not

[issue16392] import crashes on circular imports in ext modules

2012-11-06 Thread Brett Cannon
Brett Cannon added the comment: I was thinking somewhere in http://docs.python.org/3/c-api/import.html since this only comes up when you try to execute an import during extension module initialization that involves a circular import. -- ___ Python

[issue16392] import crashes on circular imports in ext modules

2012-11-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: Maybe we should add a warning in some documentation somewhere about this and then close the issue? I don't really know where to add it, in the C API docs perhaps, -- ___ Python tracker rep...@bugs.python.org

[issue16392] import crashes on circular imports in ext modules

2012-11-04 Thread Stefan Behnel
Stefan Behnel added the comment: The problem is a) that the module does not necessarily know to which place it eventually gets installed (Cython relies on the distutils Extension not lying to it, for example, which people do from time to time), and b) that the call to Py_InitModule() only

[issue16392] import crashes on circular imports in ext modules

2012-11-04 Thread Brett Cannon
Brett Cannon added the comment: It sounds like Cython has its fix and CPython knows what should eventually be changed in Python 4 to bring extension module initialization closer to how Python module code is initialized. Maybe we should add a warning in some documentation somewhere about this

[issue16392] frozen importlib crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
New submission from Stefan Behnel: After compiling the stdlib with Cython with the attached script, modules that use circular imports fail to initialise. That includes os and posixpath, as well as shutil and tarfile. Example: $ ./python -c 'import shutil' Traceback (most recent call last

[issue16392] frozen importlib crashes on circular imports in ext modules

2012-11-03 Thread Brett Cannon
Brett Cannon added the comment: I don't mean for this to sound rude, but this seems like a Cython issue and not one for the stdlib. Can you reproduce the problem without using Cython? The new per-module locking mechanism Antoine prevents this from being a problem normally, so it makes me

[issue16392] frozen importlib crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Well, it might be a legitimate issue, but due to the setup needed to reproduce, I would hope a Cython developer could do the diagnosis and possibly submit a patch. -- ___ Python tracker rep...@bugs.python.org

[issue16392] frozen importlib crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
Stefan Behnel added the comment: Well, it's not like the setup was all that difficult. 1) Install the latest github master of Cython (they provide one-click archives that pip can install for you), 2) change into the CPython stdlib directory and run the script I attached, 3) execute import os

[issue16392] frozen importlib crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
Changes by Stefan Behnel sco...@users.sourceforge.net: Added file: http://bugs.python.org/file27865/cystdlibbug.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
Stefan Behnel added the comment: Since it's quite possible that this has nothing to do with the frozen part of the importlib specifically, I'm removing that bit from the ticket title. -- title: frozen importlib crashes on circular imports in ext modules - import crashes on circular

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Are you sure this worked before 3.3? Regardless, it seems you could fix this issue by adding a single line just after the PyModule_Create() call: __pyx_m = PyModule_Create(__pyx_moduledef); #endif if (PyDict_SetItemString(PyImport_GetModuleDict(),

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: A simple test seems to confirm the problem already existed in 3.2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Note that Py_InitModule4 in Python 2 did add the module object to sys.modules (by calling PyImport_AddModule) before returning, but PyModule_Create in Python 3 doesn't. (PEP 3121 doesn't seem to mention PyModule_Create at all, strangely; it seems the PEP

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
Stefan Behnel added the comment: Hmm, we already do that for packages (i.e. when compiling __init__.py). Looks like this just needs to be done for all modules in Py3. And unless there is a compelling reason for Py_InitModule4() not to do it, I think it should be reverted to its Py2 behaviour.

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: I have detected a compatibility issue when reverting to the 2.x behaviour: extension modules which lie about their name in their PyModuleDef are broken. There are two such modules in 3.3: _io and _decimal. Patch attached, anyway. -- keywords: +patch

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Stefan Behnel
Stefan Behnel added the comment: Now that you mention it - wouldn't that suffer from not actually knowing the FQMN? There's that hack in the dynlib loader that stores the package context in a global variable so that the module creation function can figure it out. That might be a reason not to

[issue16392] import crashes on circular imports in ext modules

2012-11-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Now that you mention it - wouldn't that suffer from not actually knowing the FQMN? There's that hack in the dynlib loader that stores the package context in a global variable so that the module creation function can figure it out. That might be a reason not

Re: Question about circular imports

2012-02-28 Thread Ethan Furman
OKB (not okblacke) wrote: Anyway, testing this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate

Re: Question about circular imports

2012-02-27 Thread Jean-Michel Pichavant
Frank Millman wrote: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs

Re: Question about circular imports

2012-02-27 Thread Ian Kelly
On Sun, Feb 26, 2012 at 3:42 AM, Frank Millman fr...@chagford.com wrote: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon

Re: Question about circular imports

2012-02-27 Thread Terry Reedy
On 2/27/2012 1:16 AM, Frank Millman wrote: To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer I tested something like this with stdlib, but there must be some important difference I did not notice. It make be in the contents of

Re: Question about circular imports

2012-02-27 Thread Ian Kelly
On Mon, Feb 27, 2012 at 6:01 PM, Terry Reedy tjre...@udel.edu wrote: On 2/27/2012 1:16 AM, Frank Millman wrote: To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer I tested something like this with stdlib, but there must be some

Re: Question about circular imports

2012-02-27 Thread OKB (not okblacke)
this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate library imported by both is easier to understand, and has

Question about circular imports

2012-02-26 Thread Frank Millman
Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to access something

Re: Question about circular imports

2012-02-26 Thread Peter Otten
Frank Millman wrote: I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to access

Re: Question about circular imports

2012-02-26 Thread Frank Millman
Frank Millman fr...@chagford.com wrote in message news:jid2a9$n21$1...@dough.gmane.org... Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. [...] The second solution is - in formats/__init__.py import sys

Re: Question about circular imports

2012-02-26 Thread Frank Millman
Peter Otten __pete...@web.de wrote in message news:jid424$vfp$1...@dough.gmane.org... Frank Millman wrote: To cut a long story short, why should circular imports be unavoidable? Paths into packages are recipe for desaster. You may end up with multiple instances of the same module and your

Re: Question about circular imports

2012-02-26 Thread OKB (not okblacke)
Frank Millman wrote: The first solution is - in wavread.py - import formats.wavwrite in wavwrite.py - import formats.wavread I then have to use the full path to reference any attribute inside the imported module, which I find cumbersome. This isn't really true. If

Re: Question about circular imports

2012-02-26 Thread Terry Reedy
On 2/26/2012 6:12 AM, Peter Otten wrote: Frank Millman wrote: I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. ... This should be import sound.formats.wavread To avoid the tedious reference, follow this with read = sound.formats.wavread

Re: Question about circular imports

2012-02-26 Thread Frank Millman
To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer @Terry and OKB I tried that, but it does not work. a.py /b __init__.py c.py d.py a.py - from b import c c.py - import b.d d.py - import b.c If I run

Re: Problem with python 3.2 and circular imports

2011-03-06 Thread Frank Millman
placed 'import' statements in the main module, and it worked. Then I found the need for some modules to refer to objects in other modules, so I needed 'import' statements within the modules. I found myself hitting problems with circular imports from time to time, but with some help from

Re: Problem with python 3.2 and circular imports

2011-03-05 Thread Rafael Durán Castañeda
Thank you for your answer Frank, I think I've found the problem. I was calling modules from inside subpackages, and I need to use them from outside, so I have package in PYTHONPATH. is that correct? But now I have another question: Can I execute an script inside subpackage1 importig modules from

Re: Problem with python 3.2 and circular imports

2011-03-04 Thread Frank Millman
On February 28 2011 Rafael Durán Castañeda wrote I'm stil totally stuck with relative imports, i' ve tried the example tree from PEP 328 without any result: package/ __init__.py subpackage1/ __init__.py moduleX.py moduleY.py subpackage2/ __init__.py

Re: Problem with python 3.2 and circular imports

2011-02-28 Thread Rafael Durán Castañeda
I'm stil totally stuck with relative imports, i' ve tried the example tree from PEP 328 without any result: package/ __init__.py subpackage1/ __init__.py moduleX.py moduleY.py subpackage2/ __init__.py moduleZ.py moduleA.py Assuming that the

Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
Hi all I thought I was getting the hang of circular imports, but after upgrading to python 3.2 I am stumped again. I know some people think that circular imports are always bad, but others suggest that, provided you understand the potential problems, they can be acceptable. Assume

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Ben Finney
Frank Millman fr...@chagford.com writes: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg import mod1 mod1.py import mod2 mod2.py import mod1 What are you expecting the result to be? If it's about sharing objects between

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
suggests that you are one of those who recommend that circular imports are best avoided altogether. In an ideal world I would agree. However, the fact is that, no doubt due to a mental block I have, I do find myself in this situation from time to time, and I have not seen anything

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Steven D'Aprano
On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg import mod1 mod1.py import mod2 mod2.py import mod1 If you change the import mod* lines to import

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote in message news:4d6a56aa$0$29972$c3e8da3$54964...@news.astraweb.com... On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-08 Thread Spencer Pearson
All right, thank you for helping! I'd had a little voice in the back of my mind nagging me that it might not be logical to include a bunch of classes and function definitions in my startup file, but I never got around to splitting it up. The module/script distinction makes sense, and it seems more

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-06 Thread Dave Angel
On 2:59 PM, Carl Banks wrote: On Sep 5, 5:07 pm, Dave Angelda...@ieee.org wrote: On 2:59 PM, Carl Banks wrote: All of this gets a lot more complicated when packages are involved. Perhaps a better answer would be to import __main__ from the second module. Then what if the module is

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-06 Thread Carl Banks
On Sep 6, 4:44 pm, Dave Angel da...@ieee.org wrote: On 2:59 PM, Carl Banks wrote: On Sep 5, 5:07 pm, Dave Angelda...@ieee.org   wrote: On 2:59 PM, Carl Banks wrote: All of this gets a lot more complicated when packages are involved. Perhaps a better answer would be to import __main__ from

Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Spencer Pearson
Hi! I'm writing a package with several files in it, and I've found that isinstance doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass( object ): pass if __name__ == '__main__': a = AClass()

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Arnaud Delobelle
Spencer Pearson speeze.pear...@gmail.com writes: Hi! I'm writing a package with several files in it, and I've found that isinstance doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass( object ): pass

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Carl Banks
On Sep 5, 1:19 pm, Spencer Pearson speeze.pear...@gmail.com wrote: Hi! I'm writing a package with several files in it, and I've found that isinstance doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass(

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Dave Angel
having circular imports. This is just the most blatant of the problems that circular imports can cause. I don't know of any cases where circular dependencies are really necessary, but if one decides to use them, then two things should be done: 1) do almost nothing in top-level code in any module

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Carl Banks
? It'll try to import __main__ but get a different script than expected. But to my way of thinking, the answer should be to avoid ever having circular imports.  This is just the most blatant of the problems that circular imports can cause. I don't know of any cases where circular dependencies

[issue9657] Add circular imports test

2010-08-22 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: It would be good if the test timed out rather than deadlocking in the face of a broken import lock. I suggest: 1. Make the two test threads daemon threads 2. Specify a timeout to the join() calls 3. Use self.assertFalse(t1.is_alive()) and

[issue9657] Add circular imports test

2010-08-22 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: It would be good if the test timed out rather than deadlocking in the face of a broken import lock. I could do that indeed. I'm not sure it would be much better, though, because the lock will still be held and posterior tests may freeze

[issue9657] Add circular imports test

2010-08-22 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: Both good points - don't worry about it then. +1 to add to the test suite as-is. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9657 ___

[issue9657] Add circular imports test

2010-08-22 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Thank you Nick! I've committed the patch in r84268 (py3k) and r84269 (3.1). -- resolution: - fixed stage: patch review - committed/rejected status: open - closed versions: +Python 3.1 ___ Python

[issue9657] Add circular imports test

2010-08-21 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: Here is a test for multi-threaded circular imports (in order to exercise the import lock), following a comment by Graham Dumpleton on #9260. -- components: Tests files: circulartest.patch keywords: patch messages: 114541 nosy

Re: Circular imports (again)

2010-08-10 Thread Frank Millman
Frank Millman fr...@chagford.com wrote in message news:i3ov9e$du...@dough.gmane.org... Hi all I know the problems related to circular imports, and I know some of the techniques to get around them. However, I find that I bump my head into them from time to time, which means, I guess, that I

Circular imports (again)

2010-08-09 Thread Frank Millman
Hi all I know the problems related to circular imports, and I know some of the techniques to get around them. However, I find that I bump my head into them from time to time, which means, I guess, that I have not fully understood how to organise my code so that I avoid them in the first place

Re: Circular imports (again)

2010-08-09 Thread Ethan Furman
Frank Millman wrote: Hi all I know the problems related to circular imports... It has just happened again. I have organised my code into three modules, each representing a fairly cohesive functional area of the overall application. However, there really are times when Module A wants

Re: Circular imports (again)

2010-08-09 Thread Carl Banks
Module B, ditto for B and C, and ditto for C and A. There's a dozen reasons why circular imports can go wrong. Can you describe the problem you're having getting them to work? If there's a traceback when you try to do it, cut-and-paste the traceback and relevant code here. If it's running, but you

Re: Circular imports (again)

2010-08-09 Thread Michael Torrie
Module B, ditto for B and C, and ditto for C and A. There are a number of ways to avoid circular imports, in order of my own preference: 1. Make common stuff a new module. So if A needs something from B, and vice versa, you must factor out the stuff and stick it in its own module. The fact that you

Re: Circular imports

2007-05-29 Thread jim-on-linux
On Tuesday 29 May 2007 00:08, Carsten Haese wrote: On Mon, 28 May 2007 23:46:00 -0400, Ron Provost wrote [...] python is not happy about my circular imports [...] A circular import is not a problem in itself. I'm guessing you're running into a situation like this: Module A imports

Circular imports

2007-05-28 Thread Ron Provost
it working. However, because of all these dependancies, python is not happy about my circular imports. Is there any way to force python to accept these imports for now? the only solution I've come up with myself would be to combine all the files into one. This isn't really possible anyway because

Re: Circular imports

2007-05-28 Thread Carsten Haese
On Mon, 28 May 2007 23:46:00 -0400, Ron Provost wrote [...] python is not happy about my circular imports [...] A circular import is not a problem in itself. I'm guessing you're running into a situation like this: Module A imports module B and then defines an important class. Module B imports

circular imports

2005-05-20 Thread qhfgva
include '/general/path/' and then just use: # how I'd like them to be from aaa.bbb import foo So I thought I'd just add the necessary __init__.py files and then things would just work. Unfortunately trying this exposed a large number of circular imports which now cause the files to fail to load

Re: circular imports

2005-05-20 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: So I thought I'd just add the necessary __init__.py files and then things would just work. Unfortunately trying this exposed a large number of circular imports which now cause the files to fail to load. You didn't describe you you created the necessary __init__.py

Re: circular imports

2005-05-20 Thread qhfgva
All of the __init__.py files are empty and I don't know of any overlapping of names. Like I said this is code that works fine, I'm just trying to clean up some things as I go. Here are my working examples: x1.py == # how things work in our code now: # called with home/dlee/test/module

Re: circular imports

2005-05-20 Thread Peter Hansen
[EMAIL PROTECTED] wrote: I'm working with a large code base that I'm slowly trying to fix unpythonic features of. [...] Insead I'd rather have PYTHONPATH already include '/general/path/' and then just use: One option you might not have considered, which I find more pythonic than environment