Skip to content

Instantly share code, notes, and snippets.

@satya10x
satya10x / curr_format.py
Created May 22, 2014 18:33
Python currency formatting.
def format_currency(value, currency, add_symbol=False):
# Check if value exists
if value:
# stores the negative symbol
symbol = ""
formatted_currency = ""
dec = ""
value = str(value)
from sqlalchemy.ext.declarative import DeclarativeMeta
class AlchemyEncoder(json.JSONEncoder):
def default(self, obj):
print obj.__public__
if isinstance(obj.__class__, DeclarativeMeta):
fields = {}
for field in [x for x in obj.__public__) if not x.startswith('_') and x != 'metadata']: