Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Writing game-state data...

Reply
Thread Tools

Re: Writing game-state data...

 
 
Ian Kelly
Guest
Posts: n/a
 
      11-09-2012
On Fri, Nov 9, 2012 at 12:20 AM, Graham Fielding <> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a program to create a wireless connection. =?Utf-8?B?bWJvd3llckBwdXJkdWUuZWR1?= Wireless Networking 1 10-05-2005 12:59 PM
writing email problems? Bri Firefox 1 05-12-2005 03:03 AM
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
Unhandled exception in FileStream when writing to a full disk - bug in framework? Amit ASP .Net 8 08-04-2003 03:34 PM
A failure occurred writing to the resources file. Access is denied. -- RESX file is locked? -- WHY? Mark Kamoski ASP .Net 1 07-04-2003 12:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57