0
votes
1answer
16 views

python encode/decoder for serialization/deserialization (Java's kyro equivalence in python)

I need to convert python value into byte array and vice versa. For example: Integer 256 -> [1, 1] // 256 = 1 * 255 + 1 String 'ab' -> [97, 98] // 'a' -> 97, 'b' -> 98 Floating point 1.23 -> [63, ...
1
vote
2answers
31 views

<Django object > is not JSON serializable

I have the following code for serializing the queryset; def render_to_response(self, context, **response_kwargs): return HttpResponse(json.simplejson.dumps(list(self.get_queryset())), ...
0
votes
0answers
29 views

How to implement a remote scheduler server using python

I wanna use python to implement a remote scheduler server which provide API for others to call. For example, user can make a POST request to url http://myurl.com/Jobs with data {'job_name': 'Test1', ...
0
votes
0answers
22 views

python serialize the whole package?

although load_source of imp module is already removed from library docs (as of python 3.3), you can still use it to dynamically import python modules. it has third optional parameter, a file(or ...
1
vote
1answer
43 views

Django caching - Pickle is slow

Working on optimization of one web-site, I found, that finally pickling of QuerySets becomes bottleneck in caching, and no matter how clever your code could be, unpickling of relatively large QS in ...
0
votes
2answers
39 views

Need way to unserialize objects from PHP in Python [closed]

I have a PHP serialized object that I need to un-serialize for use in Python. I know, it is not an open format but it is what I have to work with. I saw a topic that seemed to address this here but ...
0
votes
3answers
62 views

Decoding nested JSON with multiple 'for' loops

I'm new to Python (last week), and have reached my limit. Spent three days on this, most of my time in stackoverflow, but I cannot work out how to go any further! The Json has multiple nested arrays. ...
2
votes
4answers
59 views

Output Pyodbc cursor output as Python dictionary?

How do I serialize pyodbc cursor output (from .fetchone, .fetchmany or .fetchall) as a Python dictionary? I'm using bottlepy and need to return dict so it can return it as JSON.
0
votes
2answers
80 views

Python query objects are not serializable

When I tried to encode the query objects I get the following error: File "C:\Program File\Python27\lib\json\encoder.py", line 264, in iterencode return _iterencode(o, 0) File ...
2
votes
1answer
43 views

How to make a custom exception class with multiple init args pickleable

Why does my custom Exception class below not serialize/unserialize correctly using the pickle module? import pickle class MyException(Exception): def __init__(self, arg1, arg2): ...
0
votes
0answers
57 views

I am trying to build a knowledge management system that learns dynamically. As it comes

I am trying to build a knowledge management system that in small way tries to mimic human ability to learn. It deals with both, new instances of concepts that it already knows, which allows it to ...
2
votes
3answers
92 views

Object schemas/models without ORM, DOM or forms

I've used MongoEngine a lot lately. Apart from the MongoDB integration, I like the idea of defining the structures of entities explicitly. Field definitions make code easier to understand. Also, using ...
2
votes
3answers
76 views

Save a dictionary to a file Python

Say I got a dictionary like this: Test = {"apple":[3,{1:1,3:5,6:7}],"banana":[4,{1:1,3:5,6:7,11:2}]} Now I want to save this dictionary into a temporary file so that I can reconstruct the ...
0
votes
1answer
47 views

How to use Data.MessagePack in Haskell

MessagePack is a binary serialization format, which apparently can be used from both Haskell and Python, languages that I need to mix in a project of mine. The structures that I need to serialize ...
0
votes
1answer
219 views

json.dump unable to serialize a dictionary containing a list in python

I have this part [{'scenariotestinputid': 1, 'scenarioid_id': 1, 'testinputid_id': 1}] inside a python dictionary called result. When I call json.dumps(result), I get a TypeError saying that ...
0
votes
2answers
74 views

Python list, tuple and dictionary to JSON?

What's the best way of displaying this as JSON? {'foo': 'bar'} [1,2,3,4,5] My partial solution: import json def json_tuple(*args, **kwargs): if args: if kwargs: ...
0
votes
2answers
51 views

How to JSON serialize hh:mm:ss in Python? How to query its type?

I need to serialize a python object into JSON and am having a hard time converting time-counters into JSON-play-nice form Say I have something like this: 01:20:24 # hh:mm:ss which is a time ...
15
votes
4answers
326 views

Python-like pickling of full Javascript objects

Is there any serialization framework for Javascript which would retain class and reference information like Python pickles? I.e. one could directly take a prototypial inherited class instance (not ...
0
votes
1answer
38 views

Python multithreading : manager dict not serializable

I managed to put multithreading in a python script. I use the manager of the multiprocessing module to create and share a dictionnay upon multiple threads. At the end of my script, i want to ouput ...
2
votes
3answers
115 views

Is there a python pickle equivalent library which dumps out ascii instead of binary stream?

Currently, the output from pickle is non-human readable, and thus, non editable. I'm looking for something which can do exactly the same (or very close to) pickle, whereby it can dump out all the ...
2
votes
1answer
49 views

Serializing Django model objects: Referencing to self

I have implemented natural keys on my objects and they worked. Except for one model that reference to itself. from django.db import models class Person(models.Model): name = ...
0
votes
3answers
68 views

How to obtain an object from a string?

Say I have the following class class Test: def TestFunc(self): print 'this is Test::TestFunc method' Now, I create an instance of the class Test >>> >>> t = Test() ...
0
votes
2answers
79 views

Textual reference of a method

Say I have the following: def func(): print 'this is a function and not a method!!!' class Test: def TestFunc(self): print 'this is Test::TestFunc method' I have the following ...
1
vote
2answers
205 views

Django : <django.utils.functional.__proxy__ object at 0x7feaac2761d0> is not JSON serializable

I am getting a problem in django serialization Here is my model for the state class State(models.Model): class Translation(translation.Translation): name = ...
0
votes
1answer
66 views

Unpickle sometimes makes blank objects

I'm trying to use pickle to save a custom class; something very much like the code below (though with a few methods defined on the class, and several more dicts and such for data). However, often ...
0
votes
2answers
72 views

Python: In class Foo: x = MyClass() can MyClass know the name of the variable it is assigned to?

I'd like to be able to do the following: class PrintName: def __init__( self, obj ): print obj._name class SetName: def __init__( self, name = None ): # Default name is None ...
0
votes
0answers
127 views

Serializing knn model opencv in python

I have a knn-classifier with OpenCV in a python 2.7 module and works ok, but now, I want to introduce it in my web app, I want the training method only run once and every time I send a new image, I ...
2
votes
1answer
78 views

Allowing the repr() of my class's instances to be parsed by eval()

Say I have defined a class myself and I defined a __repr__ method for it. I want to about convert it back to my object. I know that object serialization may be a good way of doing so (using the json ...
0
votes
1answer
65 views

json string fiddling

I have a python dictionary of JSON serialized values. I want to add to these serialized strings without first doing loads(...), then later doing dumps(...) - so I 'fiddle' with the serialized values: ...
4
votes
1answer
104 views

Dump JSON from string in unknown character encoding

I'm trying to dump HTML from websites into JSON, and I need a way to handle the different character encodings. I've read that if it isn't utf-8, it's probably ISO-8859-1, so what I'm doing now is: ...

1 2 3 4 5 9
15 30 50 per page