Skip to content

Instantly share code, notes, and snippets.

@lennax
lennax / __init__.py
Created April 21, 2012 00:28
Conditional NumPyPy import
"""
This is located inside a fake numpy, and could allow "import numpy"
to work invisibly on both Python and PyPy.
Not quite sure how to get files to find it.
In any case, NumPyPy is only a partial implementation of NumPy,
so it's probably not ready for unintended/untested/automatic use.
"""
import sys
# Delete current directory from module search path
@lennax
lennax / float.py
Created March 9, 2012 05:23
float regex
float_t = r"[+-]?(\d*\.\d+|\d+\.?)(e{1,2}[+-]?\d+)?"
import re
units = {
'day': 'd',
'hour': 'h',
'minute': 'm',
'second': 's',
}
# Matches only valid data (I hope)