Duncan Booth wrote: > Ilias Lazaridis wrote: > >> I would like to know, if this construct is valid, or if it can result in >> problems (that I do not see as a newcomer): >> >> 1082 try: >> 1083 from django.rework.evolve import evolvedb >> 1084 except ImportError: >> 1085 def evolvedb(): >> 1086 "Evolve Command Dummy" >> 1087 print 'Command evolvedb not imported' >> 1088 evolvedb.args ='' > > The only real problem here is that if django.rework.evolve imports > something else which doesn't exist you get your fallback code instead of > reporting the error. In other words there is a chance that you could mask a > deeper problem. > > If this worries you then you could do: > > try: > from django.rework.evolve import evolvedb > except ImportError, e: > if str(e).rsplit(' ')[-1] != 'django.rework.evolve': > raise > ... rest of code here ...
I thin I understand. If the exception is _not_ caused by 'django.rework.evolve', then it will be raised, thus I can see what caused it. Very nice! . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list