issubclass funny business

Michael Hudson mwh21 at cam.ac.uk
Tue Apr 11 20:48:19 EDT 2000


Les Schaffer <godzilla at netmeg.net> writes:

> </F> said:
> 
> > how about:
> >        if not isinstance(std, StandardArrayFileScanner):
> 
> i tried that first, but same problem.
> 
> > when you run FileScanner as a script, it's evaluated in the __main__
> > namespace.  when you import it, it's evaluated again, in the
> > FileScanner namespace.
> 
> groan.... its not intuitive (to me). because i can make CIE_Standards
> class inherit from FileScanner classes in the udder module no problem
> at runtime, so its a surprise to see it won't trace the tree properly
> at runtime for isinstance issubclass.
> 
> > solution: never import the script you use as the main program.
> 
> i am only at the testing stage. neither of these modules will be main
> at "usage" time.

This is definitely a pain.  It'd be nice if when you `reload'ed
modules that contain classes you could "smash" extant instances of
those classes so that they were instances of the new class, but I
can't for the life of me see how you might do this.

wishful-ly y'rs
Michael

-- 
  On the other hand,  the following areas are subject to boycott
  in reaction to the rampant impurity of design or execution, as
  determined after a period of study, in no particular order: 
    ...                            http://www.naggum.no/profile.html



More information about the Python-list mailing list