Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33002
| References | <SNT139-W18E5B74880062FFEECD3F5A3680@phx.gbl> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-11-09 01:13 -0700 |
| Subject | Re: Writing game-state data... |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3481.1352448857.27098.python-list@python.org> (permalink) |
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