CONSTRUCT - Python's way of Ruby's "alias_method"
duncan.booth at invalid.invalid
Thu Jun 8 15:15:52 CEST 2006
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
If this worries you then you could do:
from django.rework.evolve import evolvedb
except ImportError, e:
if str(e).rsplit(' ')[-1] != 'django.rework.evolve':
... rest of code here ...
More information about the Python-list