Import order question
Nagy L?szl? Zsolt <gandalf at shopzeus.com> writes:
> I have a class hierarchy like this:
> Widget <- VisualWidget <- BsWidget
> and then BsWidget has many descendants: Desktop, Row, Column, Navbar
None of this implies anything about which modules you place these in;
Python is not Java, and you should be putting your class definitions
wherever makes the most sense for reading and access.
> Here is the problem: these methods should create instances of Row,
> Column and Navbar. But this leads to circular imports.
It should not; Python is not Java.
Use modules to group your class definitions conceptually. There is no
need whatever to separate every class into a different module.
> * I want to put different widget classes into their corresponding
> different source files
> This might be a bad idea, but then please tell me why it is bad, and
> what would be the right code pattern for this task.
Not only does it lead to the problem you've described, it makes the code
needlessly difficult to read.
Pyth is not Java
\ ?I do not believe in forgiveness as it is preached by the |
`\ church. We do not need the forgiveness of God, but of each |
_o__) other and of ourselves.? ?Robert G. Ingersoll |