Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66097
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'assignment': 0.07; 'none:': 0.07; 'filename': 0.09; 'none):': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'self.data': 0.09; 'def': 0.12; 'wrote': 0.14; 'dict': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Object': 0.16; 'typeerror:': 0.16; 'trying': 0.19; 'stack': 0.19; 'error': 0.23; 'class.': 0.26; 'define': 0.26; 'header:X-Complaints-To:1': 0.27; 'rest': 0.29; "doesn't": 0.30; "i'm": 0.30; 'class': 0.32; 'figure': 0.32; 'skip:_ 10': 0.34; 'message.': 0.35; 'problem': 0.35; 'skip:u 20': 0.35; 'really': 0.36; 'subject:Simple': 0.36; 'similar': 0.36; 'clear': 0.37; 'being': 0.38; 'to:addr:python- list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; "you're": 0.61; 'first': 0.61; 'show': 0.63; 'subject::': 0.85; 'involved.': 0.91; 'thing,': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re:Simple Object assignment giving me errors |
| Date | Wed, 12 Feb 2014 16:41:29 -0500 (EST) |
| Organization | news.gmane.org |
| References | <d7d2865e-4184-4c05-b1bd-b4f16547b2f2@googlegroups.com> |
| X-Gmane-NNTP-Posting-Host | dpc6744192124.direcpc.com |
| X-Newsreader | PiaoHong Usenet NewsReaders 1.36 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6794.1392241090.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392241090 news.xs4all.nl 2939 [2001:888:2000:d::a6]:34015 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66097 |
Show key headers only | View raw
Nir <nirchernia@gmail.com> Wrote in message:
> This is from the book 'dive into python'. I am trying to define jeez as being an instance of FileInfo.
>
> class UserDict(object):
> def __init__(self, dict = None):
> self.data = {}
> if dict is not None: self.update(dict)
>
> class FileInfo(UserDict):
> def __init__(self, filename=None):
> UserDict.__init__(self)
> self["name"] = filename
>
>
> jeez = FileInfo("yo")
>
>
>
>
> I get a TypeError: 'FileInfo' object doesn't support item assignment .
>
> Am I missing something?
>
Yes, you're missing the rest of the error message. Show the
whole thing, including the stack trace, and I'm sure it'll be
clear that the error happened long before jeez was involved.
I figure that the line in error is
self["name"] = filename
and that what you really need is
self.data ["name"] = filename
You also have a similar problem on the last line of the first class.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simple Object assignment giving me errors Nir <nirchernia@gmail.com> - 2014-02-12 13:18 -0800
Re: Simple Object assignment giving me errors Chris Angelico <rosuav@gmail.com> - 2014-02-13 08:26 +1100
Re:Simple Object assignment giving me errors Dave Angel <davea@davea.name> - 2014-02-12 16:41 -0500
Re: Simple Object assignment giving me errors Nir <nirchernia@gmail.com> - 2014-02-12 13:42 -0800
Re: Simple Object assignment giving me errors Chris Angelico <rosuav@gmail.com> - 2014-02-13 08:48 +1100
Re: Simple Object assignment giving me errors Jerry Hill <malaclypse2@gmail.com> - 2014-02-12 17:09 -0500
Re: Simple Object assignment giving me errors Nir <nirchernia@gmail.com> - 2014-02-12 14:25 -0800
csiph-web