>
> I suspect, if you can be explicit about the goal you're aiming for with
> this code, a better design can be found that doesn't require all those
> polymorphism-breaking type checks.
>
It is difficult to explain what I am trying to do, but let me try. I
am mapping data from one hierarchy into an
Hi,
I want to apply a "convert" function on an object as follows:
If the object is of MyType type, invoke the passed in function.
If the object is a dictionary, apply on the keys and values of the
dictionary recursively.
If the object is a set, list or tuple, apply on each element
recursively.
Else
Hi,
For purposes I don't want to go into here, I have the following code:
def handleObj(obj):
if isinstance(obj, MyType):
return obj.handle()
elif isinstance(obj, (list, tuple, set)):
return obj.__class__(map (handleObj, obj))
elif isinstance(obj, dict):
return obj.__class__((h
On Nov 13, 10:28 am, hetchkay wrote:
> On Nov 13, 9:50 am, John Yeung wrote:
>
>
>
> > On Nov 12, 11:22 pm, r wrote:
>
> > > On Nov 12, 10:07 pm, hetchkay wrote:
> > > > I have the following in exit.py:
> > > > import sys
>
On Nov 13, 9:50 am, John Yeung wrote:
> On Nov 12, 11:22 pm, r wrote:
>
>
>
> > On Nov 12, 10:07 pm, hetchkay wrote:
> > > I have the following in exit.py:
> > > import sys
> > > sys.exit(0)
>
> > > I now try 'python -i exit.py
Hello,
Thanks for your help.
I know what SystemExit is. In 2.5 as well SystemExit is raised when
sys.exit() is called. For example:
try:
import sys
sys.exit(0)
except SystemExit:
print "system exit raised"
raise
But I don't understand why the interpreter does not exit in 2.6 but
does exi
Hello,
I have the following in exit.py:
import sys
sys.exit(0)
I now try 'python -i exit.py':
In 2.5, the script exits as I would expect.
In 2.6, the following error is printed:
Traceback (most recent call last):
File "exit.py", line 2, in
sys.exit(0)
SystemExit: 0
>>>
I couldn't find