Re: [Tutor] Handling function parameters of mixed object and basic types

2006-09-04 Thread Kent Johnson
Duncan Gibson wrote: > I've taken over someone else's code (yes, honestly!) that has a > complex class hierarchy on top of the main procedural code. This > is unfortunate because it means that isinstance() is everywhere. > > Profiling recently highlighted one particular formatted output > function

Re: [Tutor] Handling function parameters of mixed object and basic types

2006-09-04 Thread Duncan Gibson
I wrote: > >def newOutput(x): > >if x is None: > >pass > >return > >try: > >x.output() > >except AttributeError: > >if isinstance(x, int): > >pass > >elif isinstance(x, float): > >

Re: [Tutor] Handling function parameters of mixed object and basic types

2006-09-04 Thread Alan Gauld
> I've taken over someone else's code (yes, honestly!) that has a > complex class hierarchy on top of the main procedural code. This > is unfortunate because it means that isinstance() is everywhere. It shouldn't do. Multiple uses of isinstance is usually a sign of bad OO design, regardlerss of wh

[Tutor] Handling function parameters of mixed object and basic types

2006-09-04 Thread Duncan Gibson
I've taken over someone else's code (yes, honestly!) that has a complex class hierarchy on top of the main procedural code. This is unfortunate because it means that isinstance() is everywhere. Profiling recently highlighted one particular formatted output function that has a cascade of isinstan