[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  ArrayImport and python dicts
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

ArrayImport and python dicts

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Posted by Mr Anonymous   (8 posts)  [Biography] bio
Date Mon 14 Mar 2005 04:01 PM (UTC)
So, much to my dismay I discovered that I couldn't save a dict in a variable. However, I did discover arrays. One feature they seem to lack is a direct import from a python dictionary straight into the array using ArrayImport, as they are direct equivalents. Can this be considered for a future version? Or, if it's already possible without having to use a workaround using for loops, can someone tell me how it's done?
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Tue 15 Mar 2005 08:07 AM (UTC)
You can try using pickle for that - just saving and loading a dictionary to/from a variable:

import pickle

#create the dictionary
d = {"1" : 1, "2" : 2, "3" : 3}

#save it in a variable
world.SetVariable("d_DICT", pickle.dumps(d))

#delete the dictionary object
del d

#load it from the variable
d = pickle.loads(world.GetVariable("d_DICT"))

[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]