Please always send the full error trace not just the last line. The message is full of useful details which we can't currently see.
On 07/04/17 09:28, Allan Tanaka via Tutor wrote: > Hi > I have added b so that it translates into bytes object. save_cPickle part is > not problem... > But i still get an error when coming into load_cPickle for this function: > Dataset.save_part_features('categorical_counts', > Dataset.get_part_features('categorical')) > although i have defined b in save_cPickle > > THE CODE: > import _pickle as cPickle > def save_cPickle(filename, data): > with open(filename, 'wb') as f: > cPickle.dump(data, f) > > > def load_cPickle(filename): > with open(filename) as f: > > return cPickle.load(f) > > class Dataset(object): > > part_types = { > 'id': 'd1', > 'loss': 'd1', > } > parts = part_types.keys() > > @classmethod > def save_part_features(cls, part_name, features): > save_cPickle('%s/%s-features.pickle' % (cache_dir, part_name), features) > > @classmethod > def get_part_features(cls, part_name): > return load_cPickle('%s/%s-features.pickle' % (cache_dir, part_name)) Does the class add anything here given it only has two class attributes and two class methods? If you aren't going to create instances then a simple module level function is probably as useful. > Dataset.save_part_features('categorical_counts', > Dataset.get_part_features('categorical')) > Dataset(categorical_counts=train_cat_counts).save('train') This tries to create an instance of Dataset but there is no matching init() method...nor is there a save() method. ??? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor