Skip to content

Instantly share code, notes, and snippets.

@dpallot
dpallot / aecho.py
Created December 16, 2015 07:44 — forked from dabeaz/aecho.py
Live-coded examples from my PyCon Brasil 2015 Keynote
# aecho.py
from socket import *
import asyncio
loop = asyncio.get_event_loop()
async def echo_server(address):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
@dpallot
dpallot / gist:0352d38a061103ae98f8
Last active August 29, 2015 14:22
Asyncio stdio
import os
import asyncio
import sys
from asyncio.streams import StreamWriter, FlowControlMixin
reader, writer = None, None
@asyncio.coroutine
def stdio(loop=None):
@dpallot
dpallot / beautiful_idiomatic_python.md
Last active March 16, 2022 04:37 — forked from JeffPaine/beautiful_idiomatic_python.md
Beautiful Idiomatic Python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: