Python Forum
can i nest dictionary in array?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can i nest dictionary in array?
#1
In my last post ,I talked about saving all object location in variable and save it too a file,but they answer that doing things with file is one of the most slowest thing a computer can do(cause game to be slow),so I found a new way as an alternative,but I also have another problem.

Can I nest dictionaries in an array?
If so,can I use
array.append(dictionary)

I saw many people browsing this thread,but none of you is answering,why?
Reply
#2
Do you mean array.array or this:

In [1]: l = []

In [2]: for k in range(1, 11):
    ...:     l.append({k: k**2})
    ...:     

In [3]: l
Out[3]: 
[{1: 1},
 {2: 4},
 {3: 9},
 {4: 16},
 {5: 25},
 {6: 36},
 {7: 49},
 {8: 64},
 {9: 81},
 {10: 100}]
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
(Feb-01-2017, 12:00 PM)hsunteik Wrote: In my last post ,I talked about saving all object location in variable and save it too a file,but they answer that doing things with file is one of the most slowest thing a computer can do(cause game to be slow),so I found a new way as an alternative,but I also have another problem.

Can I nest dictionaries in an array?
If so,can I use
array.append(dictionary)

I saw many people browsing this thread,but none of you is answering,why?

Yes, you can.

Note that using files and arrays are two orthogonal issues, the array won't survive the program stopping.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to let the user add 'None' to an specific array in a dictionary? noahverner1995 4 1,784 Dec-26-2021, 10:03 AM
Last Post: noahverner1995
  how to nest loop for 4*4 scatter plot kassamohammed 0 2,571 Jun-23-2020, 09:47 AM
Last Post: kassamohammed

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020