hi,
I am trying to dump a class object using cPickle in python component for grasshopper but it returns the following exception.
Runtime error (ImportException): No module named __main__
I am not really familiar with python and exception but I pretty sure that it should work. Any help would be greatly appreciated. thx
https://docs.python.org/2/library/pickle.html
import cPickle as pickle
class DoSomething:
def __init__(self, talk, eat, drink):
self.talk = talk
self.eat = eat
self.drink = drink
#dump
test = DoSomething('hello','pasta','nama biru')
output = open('D:\pklTest01.pkl', 'wb')
pickle.dump(test, output)
output.close()
#load
input = open("D:\pklTest01.pkl", "rb")
a = pickle.load(input)
print (a.talk)
print (a.eat)
print (a.drink)
>>>'hello'
>>>'pasta'
>>>'nama biru'