def gene_view(request, slug=None, gene=None, org=None, template=None):
print(KeyError)
and I get this exception with django 1.4 (if it matters):
UnboundLocalError at /predictions/gene/
local variable 'KeyError' referenced before assignment
<etc>
In ./manage.py shell though, I can do:
./manage.py shell
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import urls
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import predictions.views
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import predictions.urls
>>> print(KeyError)
<type 'exceptions.KeyError'>
I was expecting that if there was some redefinition of KeyError that
one of those would also give the exception. I've also tried this,
just for kicks:
>>> from urls import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> from predictions.views import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> from predictions.urls import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>>
I'm not really sure where to start tracking this down. I'm under the
impression that KeyError is one of the built in python exceptions, and
so it should really never be unbound.
Thanks for your help!
Casey
Python thinks KeyError is a local variable, thus it sounds like code
in the view subsequent to where KeyError is caught makes an assignment
to KeyError. So search later in the view for where KeyError is
mis-assigned.
Karen
--
http://tracey.org/kmt/
After changing it to:
except (ValueError, KeyError)
the issue is resolved.
Thanks so much!
Casey
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>