Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33002
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.061 |
| X-Spam-Evidence | '*H*': 0.88; '*S*': 0.00; 'assign': 0.07; 'type,': 0.07; 'file,': 0.15; 'file.close()': 0.16; 'subject:Writing': 0.16; 'wrote:': 0.17; 'trying': 0.21; 'player': 0.23; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'objects': 0.29; 'probably': 0.29; 'fri,': 0.30; 'error': 0.30; 'file': 0.32; 'message.': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'built-in': 0.35; 'nov': 0.35; 'open': 0.35; 'received:74.125': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'map': 0.61; 'subject:...': 0.63; 'here': 0.65; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=E25BkiFWPwi4GPhZ+lmzG5cA71psMghWN8Q/cuh7ngE=; b=KldIxCMb8LHnk0YButupBf+YPoLwjo5lN6yYpjLpF4OLRsU0wiVJ5Aoxu41Hw8Uiu/ PAinN98VRKIvnaH+lznPVKY8CIsEzWRF3Slp78ouit/LGLOk1dufgO+8gVZq8X0hg4Q1 KWVCYf0GQpMMTN+M2qyQEk8G4LmZuPwl4vt8GS9cbeDGUwsVVcKcjNyS1+4QRxO6DLpF U9uEz/tlLlqG3IASuW32GqgAFV3EKtTqrxPwSQGGH/XjvfKE9RM2XhNnw7zy9TpPFCYr veBCX/AHgiegSMxY6lqdgo/EMuxDlRH1X5z6BU90luu7s7dn0QS2bJUZemHvqYPznZjD K2nA== |
| MIME-Version | 1.0 |
| In-Reply-To | <SNT139-W18E5B74880062FFEECD3F5A3680@phx.gbl> |
| References | <SNT139-W18E5B74880062FFEECD3F5A3680@phx.gbl> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 9 Nov 2012 01:13:45 -0700 |
| Subject | Re: Writing game-state data... |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3481.1352448857.27098.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352448857 news.xs4all.nl 6952 [2001:888:2000:d::a6]:33767 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33002 |
Show key headers only | View raw
On Fri, Nov 9, 2012 at 12:20 AM, Graham Fielding <frednotbob@hotmail.ca> wrote:
> file_object = open('savegame.sav', 'wb')
Here you open a file and assign it to "file_object".
> file['map'] = map
Here you attempt to write to "file" instead of "file_object". "file"
is the name of a built-in type, hence your error message.
Since you seem to be trying to use shelve, you should also probably be
calling shelve.open to open the file, not just open.
> file['objects'] = objects
> file['player_index'] = objects.index(player) #index of player in
> objects list
> file['inventory'] = inventory
> file['game_msgs'] = game_msgs
> file['game_state'] = game_state
> file['stairs_index'] = objects.index(stairs)
> file['dungeon_level'] = dungeon_level
> file.close()
Same issue for all these other statements.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Writing game-state data... Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 01:13 -0700
csiph-web