| bio | website | |
|---|---|---|
| location | ||
| age | ||
| visits | member for | 9 months |
| seen | Mar 29 at 10:12 | |
| stats | profile views | 8 |
>>> from collections import defaultdict
>>> import json
>>> def tree(): return defaultdict(tree)
>>> t = tree()
>>> t['a']['b'] = 'foo'
>>> t['a']['c'] = 'bar'
>>> json.dumps(t)
'{"a": {"c": "bar", "b": "foo"}}'
.
>>> from operator import methodcaller
>>> methodcaller('__call__', 2, 10)(pow)
1024
.
>>> getattr(__import__('sys'), 'stdout').write('hello\n')
.
>>> class A(object):
... pass
...
>>> a = A()
>>> b = A()
>>> def foo(self):
... print "foo"
...
>>> import types
>>> a.foo = types.MethodType(foo, a)
>>> a.foo()
foo
>>> b.foo()
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'A' object has no attribute 'foo'
This user has not asked any questions
|
|
Stack Overflow | 1,961 rep | 1220 |
|
|
Programming Puzzles & Code Golf | 111 rep | 4 |
|
|
Ask Ubuntu | 101 rep | 3 |
|
|
Unix & Linux | 101 rep | 3 |
|
|
Code Review | 101 rep | 3 |
This user has no active bounties
40 Votes Cast
| all time | by type | ||||
|---|---|---|---|---|---|
| 40 | up | 11 | question | ||
| 0 | down | 29 | answer | ||