Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33001
| 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!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; 'purpose.': 0.07; 'function:': 0.09; 'issue?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'typeerror:': 0.09; 'def': 0.10; 'stack': 0.15; 'file.close()': 0.16; 'folks,': 0.16; 'one)': 0.16; 'overwriting': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Writing': 0.16; 'trace,': 0.16; 'wrote:': 0.17; 'trying': 0.21; 'assignment': 0.22; 'player': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'guess': 0.27; 'header:X-Complaints- To:1': 0.28; '(possibly': 0.29; 'objects': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'function': 0.30; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'dies': 0.33; 'to:addr:python-list': 0.33; 'list': 0.35; 'received:org': 0.36; 'created': 0.36; "i'll": 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'does': 0.37; 'item': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'object': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'save': 0.61; 'map': 0.61; 'subject:...': 0.63; 'here': 0.65; 'now:': 0.71; 'hey,': 0.72; 'again!': 0.84; 'dark': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Writing game-state data... |
| Date | Fri, 09 Nov 2012 07:37:56 +0000 |
| References | <SNT139-W18E5B74880062FFEECD3F5A3680@phx.gbl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-78-146-8-197.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
| In-Reply-To | <SNT139-W18E5B74880062FFEECD3F5A3680@phx.gbl> |
| X-Antivirus | avast! (VPS 121108-1, 08/11/2012), Outbound message |
| X-Antivirus-Status | Clean |
| 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.3480.1352446732.27098.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352446732 news.xs4all.nl 6953 [2001:888:2000:d::a6]:57961 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33001 |
Show key headers only | View raw
On 09/11/2012 07:20, Graham Fielding wrote:
>
> Hey, folks, me again! I've been puzzling over this for a while now: I'm trying to write data to a file to save the state of my game using the following function: def save_game():
> #open a new empty shelve (possibly overwriting an old one) to write the game data
> file_object = open('savegame.sav', 'wb')
> file['map'] = map
> 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() However, while 'savegame.sav' is created in the directory I specify, the function dies on file['map'] = map. This is the end of the stack trace:
> File "C:\Python Project\Roguelike.py", line 966, in save_game
> file['map'] = map
> TypeError: 'type' object does not support item assignment Now, the map is randomly generated -- could that be an issue? Should I just scrap the current system and use pickle?
>
Please always give the complete stack trace, it's provided for a
purpose. Here I'll grope around in the dark and guess that you need
file_object = shelve.open(...
--
Cheers.
Mark Lawrence.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Writing game-state data... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-09 07:37 +0000
csiph-web