After taking a break and working on another section, I finally found what
was causing the issue. There was, indeed, an error elsewhere within that
controller, which was causing me all the headache. I appreciate your guys'
help! Thanks.
On Sunday, March 11, 2018 at 11:14:27 PM UTC-4, Drew Howell wrote:
>
> I seem to be having issues getting defaultdict to work within Web2Py. I am
> using Web2Py version 2.16.1 (Python 2.7.11).
>
> Here is the code in my controller:
> from collections import defaultdict
> g = defaultdict(list)
> g['someKey'].append('someValue')
>
> Here is the error I'm getting:
>
> File "D:/web2py/applications/fpr/controllers/students.py"
> <http://127.0.0.1:8000/admin/default/edit/fpr/controllers/students.py>, line
> 14, in view
> g['someKey'].append('someValue')
> AttributeError: 'dict' object has no attribute 'append'
>
> If I do the same thing in the Python Interpreter, I don't seem to get the
> issue.
>
> >>> from collections import defaultdict
> >>> g = defaultdict(list)
> >>> g['k'].append('v')
> >>> print g['k']
> ['v']
>
> Am I implementing this wrong or is there some sort of issue with using
> defaultdict(list) in Web2Py?
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.