mutlifile inheritance problem simplified

Pearu Peterson pearu at cens.ioc.ee
Sat Mar 23 13:33:47 EST 2002


On Sat, 23 Mar 2002, Marc wrote:

> I'm wondering whether or not this is a bug, which I would report, or
> whether I'm doing something incorrectly.

Though Python documentation on reload function warns about several
cavecats, I still could not explain the exceptions you report. But I bet
that this just is another undocumented cavecat with using reload (see
below). So, I think you should make a bug report.

After playing with your example, I concluded in the following rule (it
is possible that Python docs has relevant remarks, I just have not
found the right place yet):

  If you reload a module, then you must reload all other modules that
  use this module (usage in the sense that they define classes derived
  from a class defined in the first module). The order of reloading
  matters.

If you follow this rule, you'll have no trouble. 

Your example obviously fails to satisfy this rule because reload(c01)
forces reload(a01) but then also b01 must be reloaded. If you then
reload(b01), reload(a01) is forced but then also c01 must be reloaded. And
so on.. (in Estonia we would say "nokk lahti, saba kinni, saba lahti,
nokk kinni, nokk lahti, saba kinni, ...").

For a fix
1) remove reload(a01) statements in files b01.py and c01.py
2) if you modify a01.py, then execute
  reload(a01)
  reload(b01)
  reload(c01)
(in that order)
3) if you modify b01.py, then execute
  reload(b01)
(no need to reload a01 or c01)
4) if you modify c01.py, then execute
  reload(c01)
(no need to reload a01 or b01)

Regards,
	Pearu






More information about the Python-list mailing list