Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66093
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'assignment': 0.07; 'tries': 0.07; 'filename': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'assignment.': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'notation': 0.16; 'subject:Object': 0.16; 'typeerror:': 0.16; 'userdict': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'written': 0.21; 'help.': 0.21; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'simpler': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'specifically': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '13,': 0.31; 'though.': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'problem': 0.35; "can't": 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'subject:Simple': 0.36; 'detail': 0.37; 'handle': 0.38; 'rather': 0.38; 'that,': 0.38; 'itself': 0.39; 'sure': 0.39; "you're": 0.61; "you've": 0.63; 'more': 0.64; 'occur': 0.65; 'of:': 0.68; 'gain': 0.79; 'actually,': 0.84; 'dict,': 0.84; 'dict.': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=bflJKp1BnNO8RItcKlhcFbHgpG3BGgeZbOOhzDKdg4k=; b=vrOWMGvJcH/XYCStJn4LIry2iVg8MFFch8aIv95HiYiFyGX1eSyxFp+hPuZTs2Bpq1 75+247GnWe7tm/GZrZQro9/yFkNi70RJitd1GH1AVDOIdPlmTFVhERDDYmCaFD0z2ACD d4ChAsxLemLG8LjxMdJrr3u5Xajqni+uwWv+sAcisWC8qHx8bYCWQqFJ44xGm1UE54Dh HPPJDcKQcHbzrt6Hg+04JuZXaaSxJX0opI8cGCdl59yAuDdrbhv+8DVpR97yXei9bkZL ndxRnY6B9XblEiJ2HXe+FyQIoum/SgbLlRZOtNCxoKXVK++pn+0NL4BFfqdlMdqJciNB f0Og== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.200.74 with SMTP id jq10mr6210342pbc.169.1392240396303; Wed, 12 Feb 2014 13:26:36 -0800 (PST) |
| In-Reply-To | <d7d2865e-4184-4c05-b1bd-b4f16547b2f2@googlegroups.com> |
| References | <d7d2865e-4184-4c05-b1bd-b4f16547b2f2@googlegroups.com> |
| Date | Thu, 13 Feb 2014 08:26:36 +1100 |
| Subject | Re: Simple Object assignment giving me errors |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.6790.1392240405.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392240405 news.xs4all.nl 2850 [2001:888:2000:d::a6]:46277 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66093 |
Show key headers only | View raw
On Thu, Feb 13, 2014 at 8:18 AM, Nir <nirchernia@gmail.com> wrote: > class FileInfo(UserDict): > def __init__(self, filename=None): > UserDict.__init__(self) > self["name"] = filename > > I get a TypeError: 'FileInfo' object doesn't support item assignment . > > Am I missing something? You can't use square-brackets notation like that, unless you've written your class specifically to handle it. More likely, what you want is one of: self.name = filename self.dict["name"] = filename Also, the same problem will occur with the UserDict, which tries to update itself rather than its dict. Actually, a simpler solution might be to have UserDict inherit from dict. I'm not sure what you're trying to achieve here; more detail would help. But if UserDict really is a dict, then you can call self.update, and you can use square-brackets item assignment. I've no idea what you'd gain over just using a dict though. ChrisA
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