Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33002 > unrolled thread

Re: Writing game-state data...

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-11-09 01:13 -0700
Last post2012-11-09 01:13 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Writing game-state data... Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 01:13 -0700

#33002 — Re: Writing game-state data...

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-11-09 01:13 -0700
SubjectRe: Writing game-state data...
Message-ID<mailman.3481.1352448857.27098.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web