Skip to content

Instantly share code, notes, and snippets.

@eatonphil
eatonphil / py_js_oo.py
Last active August 29, 2015 14:17
Javascript-Style Objects in Python
# After spending too much time away from Python on Javascript, I gave this a shot. To my surprise, it worked!
# Since Python doesn't bind "self" implicitly in classes, this looks pretty similar to Python classes.
# You want inheritance? Pass in the Parent "class" and copy the key/vals a la Javascript.
# Even adding dot syntax is not too tough.
def Cat(legs, colorId, name):
def sayHi():
print 'Hi, my name is %s. I have %s legs and am %s.' % (this['name'], this['legs'], this['color'])
this = {
@jprjr
jprjr / Dockerfile
Created November 26, 2013 23:09
Setting up pyenv in docker
FROM tianon/centos-null:5.9
RUN rpm -i http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
RUN yum -y update
RUN yum -y install gcc git curl make zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl openssl-devel
RUN useradd -m python_user
RUN ln -s /proc/self/fd /dev/fd