3 ms·
Django admin awesomeness
- RyanMcGreal 17y agoWhoa - you can put a class definition inside a function definition?
- seiji 17y agoThat's tame. Here's a scary example [1] (redefining a (built in) function in the middle of a running coroutine): def foo(x): yield len(x) yield len(x) >>> g = foo(range(5)) >>> g.next() 5 >>> len = lambda y: 8 >>> g.next() 8 This causes problems when trying to implement an efficient python. You have to re-lookup your function bindings every time. [1]: Example taken from Colin's Unladen Swallow presentation http://llvm.org/devmtg/2009-10/Winter_UnladenSwallowLLVM.pdf http://llvm.org/devmtg/2009-10/Winter_UnladenSwallowLLVM.pdf
- dschobel 17y agokind of aside, does python support real coroutines yet or is it still just generators?
- uriel 17y agoAFAIK only Stackless Python supports real coroutines. There is also pycsp: http://code.google.com/p/pycsp/ http://code.google.com/p/pycsp/
- superjared 17y agoYou should look at greenlet. Pretty cool stuff, used heavily in eventlet and gevent.