Import order question

Terry Reedy tjreedy at udel.edu
Mon Feb 17 16:35:07 CET 2014


On 2/17/2014 8:01 AM, Nagy László Zsolt wrote:
> I have a class hierarchy like this:
>
> Widget <- VisualWidget <- BsWidget
>
> and then BsWidget has many descendants: Desktop, Row, Column, Navbar etc.
>
> Widgets can have children. They are stored in a tree. In order to manage
> the order of widgets, I need methods to append children. (And later:
> insert or prepend because they also have an order). So I would like to
> have methods like this:
>
> BsWidget.AppendNavbar(....)
> BsWidget.AppendRow(...)

I would write one prepend/insert/append method that 
prepends/inserts/appends the widget passed.

> Here is the problem: these methods should create instances of Row,
> Column and Navbar.

I disagree, without strong justification. Create the instances by 
directly calling the classes and do with them as you want.

-- 
Terry Jan Reedy





More information about the Python-list mailing list