#16001 closed Cleanup/optimization (invalid)
template.Context.pop does not behave as dict.pop
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I don't know if it is worth to change the code, but at least it should be documented with a docstring: one expects Context to be a dictionary like object and in this case the abstraction does not work
Change History (5)
comment:1 by , 14 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 14 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → reopened |
comment:3 by , 14 years ago
- forgot code tags, sorry:
>>> from django.template import Context >>> d = {} >>> t = Context() >>> d['key'] = 'val' >>> t['key'] = 'val' >>> d.pop('key') 'val' >>> t.pop('key') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: pop() takes exactly 1 argument (2 given)
comment:4 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
While I can understand the confusion I think pop and push are described fairly well in the documentation here: http://docs.djangoproject.com/en/1.3/ref/templates/api/#playing-with-context-objects. As described, context objects are stacks. I think this probably covers it in enough detail so closing as invalid.
comment:5 by , 14 years ago
That's ok, it's mostly cosmetic, but a couple of docstrings would have been good practice, as Context behaves both as a dict and as a list.
I was being scrupulous as the API is usually very intuitive, but this fooled me. bye
What do you expect and what do you get?