Skip to content

Instantly share code, notes, and snippets.

View jbvsmo's full-sized avatar

João Bernardo Oliveira jbvsmo

View GitHub Profile
@jbvsmo
jbvsmo / gist:6617413
Created September 18, 2013 23:56
In place operation for mutable objects
>>> a = [1]
>>> b = a
>>> a += [2]
>>> a
[1, 2]
>>> b
[1, 2]
>>> a = a + [3]
>>> a
[1, 2, 3]
@jbvsmo
jbvsmo / gist:4958012
Last active December 13, 2015 18:48
Creating Enums with getattr syntax.
'''
>>> Enum.Colors.red.green.blue()
<Enum: Colors>
>>> Colors.red
<Colors.red = 0>
>>> Colors.green
<Colors.green = 1>
>>> Colors.blue
<Colors.blue = 2>