2

I made a class in python like the following:

class myClass():
    _fields_ = [1, 2]

where field_1 & field_2 are supposed to be integers.

Then I created an array that its elements are of the class myClass as following:

array = [ myClass() for i in range(5)]

When I wanted to check the values of the elements of array in the variable inspector, it gives my the following message:

"Spyder was unable to retrieve the value of this variable from the console." 
"The error message was: Object array is not picklable"

My question is: How can I check the values of the elements of the array?

philippos
  • 1,142
  • 5
  • 20
  • 41
  • Why do you have "graph" in the title and "array" in the question? These two words mean very different things. – DYZ May 10 '17 at 03:40
  • Possible duplicate of [Spyder Python "object arrays are currently not supported"](http://stackoverflow.com/questions/41494358/spyder-python-object-arrays-are-currently-not-supported) – stovfl May 10 '17 at 07:13
  • If you are using python 2 extending `class myClass(object)` might be sufficient. (SyntaxTip: class names start by an Upper-case letter). – Imanol Luengo May 10 '17 at 07:14
  • 1
    @stovfl the Spyder version is 2.3.7 – philippos May 10 '17 at 10:42
  • @ImanolLuengo I did the edits you suggested, but still couldn't check the array in the variable inspector. – philippos May 10 '17 at 10:43
  • @SergeBallesta You are right. It was mistyping and I edited the question. – philippos May 10 '17 at 10:45
  • @SergeBallesta: Have you a source/link for this statement: _**And a class object is indeed not pickable...**_ – stovfl May 10 '17 at 11:20

1 Answers1

1

Check out the following Spyder related sites:

: Downloads, bug reports and feature requests
: Discussions


Verifyed, pickle can handle object array given in Question.
The following works without failure.

pick_array = pickle.dumps(array)
unpick_array = pickle.loads(pick_array)

Tested with Python:3.4.2


To verify your Spyder is able to show a array at all, check the following:

array = [ i for i in range(5)]

Try to show the variable array with Inspector.

If you are able to view the variable, it's a limitation from your Spyder Version to handle object array.

stovfl
  • 14,998
  • 7
  • 24
  • 51
  • Actually I already tried this solution and it worked. According to what you said it's a limitation in my Spyder to handle the object. Any suggestions to solve this issue? – philippos May 10 '17 at 12:01