Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
biasmv committed Nov 1, 2015
1 parent eaed774 commit 95b24e5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pvviewer/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
except NameError:
string_base_type = str

def encode(obj):

def encode(obj):
"""
Dead-simple serialization of Python objects to JavaScript. The serialization
format is not pure JSON, but instead is allowed to contain arbitrary JS
expressions such as function calls. Basic data types (strings, numbers,
bool, dict, list) are directly converted to their JS counterpart. Custom,
user-defined objects must have a to_js method defined on them that converts
the object to a string. Note that the object strings are not escaped, so
the to_js methods are allowed to arbitrary expressions themselves.
"""
if hasattr(obj, 'to_js'):
return obj.to_js()
if isinstance(obj, bool):
Expand Down

0 comments on commit 95b24e5

Please sign in to comment.