Skip to content

Instantly share code, notes, and snippets.

write code for humans

Naveen Yadav navyad

write code for humans
Block or report user

Report or block navyad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:b019498dcd3f29c51d3ea18e71fc9f71
from builtins import property as _property, tuple as _tuple
from operator import itemgetter as _itemgetter
from collections import OrderedDict
class point(tuple):
'point(x, y, z)'
__slots__ = ()
_fields = ('x', 'y', 'z')
navyad / gist:f069103b4d10fc2dad19ea9dcd87e60d
Created May 24, 2018
default values without KeyError
View gist:f069103b4d10fc2dad19ea9dcd87e60d
In [1]: from collections import defaultdict
In [2]: dd = defaultdict(lambda: 100, a=22, b=11)
In [3]: dd
Out[3]: defaultdict(<function __main__.<lambda>>, {'a': 22, 'b': 11})
In [4]: dd.update({"c": 33})
In [5]: dd
navyad /
Created Aug 2, 2016
methods for API responses
from django.http.response import JsonResponse
def _send(data, status_code):
Generic method to send the JSON response
return JsonResponse(data=data, status=status_code)
You can’t perform that action at this time.