Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Python
➜ ArrayImport and python dicts
ArrayImport and python dicts
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Mr Anonymous
(8 posts) Bio
|
Date
| Mon 14 Mar 2005 04:01 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Tue 15 Mar 2005 08:07 AM (UTC) |
Message
| 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"))
| 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.
11,752 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top