Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import requests | |
class HoverException(Exception): | |
pass | |
class HoverAPI(object): | |
def __init__(self, username, password): | |
params = {"username": username, "password": password} | |
r = requests.post("https://www.hover.com/api/login", params=params) |
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications
like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.
open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl
You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html
From FastAPI Gitter: | |
dmontagu @dmontagu 00:14 | |
@wshayes @intrepidOlivia here is a fully self-contained working implementation of a wrapped response | |
https://gist.github.com/dmontagu/9abbeb86fd53556e2c3d9bf8908f81bb | |
you can set context data and errors on the starlette Request and they get added to the response at the end | |
(@intrepidOlivia if you save the contents of that gist to main.py it should be possible to run via uvicorn main:app --reload) | |
if the endpoint failed in an expected way and you want to return a StandardResponse with no data field, you provide the type of StandardResponse you want to return instead of an instance |
__author__ = "Yasunobu OKAMURA" | |
__copyright__ = "Copyright (c) 2012 Y.Okamura" | |
__license__ = "GPL v3+" | |
import xml.parsers.expat | |
import networkx as nx | |
class XGMMLParserHelper(object): | |
""" | |
""" |
[ | |
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" }, | |
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" } | |
] |
import asyncio | |
import json | |
import logging | |
from uuid import UUID | |
import aio_pika | |
import websockets.exceptions as ws_exc | |
from fastapi import APIRouter, Path | |
from starlette import status | |
from starlette.websockets import WebSocket |