Home
Welcome
About This Wiki
sandbox (play here)
This shows you the differences between two versions of the page.
python:python [2014/03/29 21:48] dblume |
python:python [2015/04/19 14:05] (current) dblume [Python] |
||
---|---|---|---|
Line 7: | Line 7: | ||
* [[http://pytools.codeplex.com/releases/view/76089|Python Tools for Visual Studio 2010]]. | * [[http://pytools.codeplex.com/releases/view/76089|Python Tools for Visual Studio 2010]]. | ||
* [[http://wiki.python.org/moin/PythonSpeed/PerformanceTips|Python Performance Tips at the Python wiki]]. | * [[http://wiki.python.org/moin/PythonSpeed/PerformanceTips|Python Performance Tips at the Python wiki]]. | ||
- | * Of course, there's getting Python running under Xampp. [[xampp]] | + | * Of course, there's [[:xampp|getting Python running under Xampp]]. |
* There's [[http://www.infoworld.com/d/application-development/pillars-python-six-python-web-frameworks-compared-169442|A comparison of CubicWeb, Django, Pyramid, Web.py, Web2py, and Zope 2]] | * There's [[http://www.infoworld.com/d/application-development/pillars-python-six-python-web-frameworks-compared-169442|A comparison of CubicWeb, Django, Pyramid, Web.py, Web2py, and Zope 2]] | ||
* Look into the microframework [[http://flask.pocoo.org/|Flask]]. Here's a [[http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world|tutorial on making a blog with it]]. | * Look into the microframework [[http://flask.pocoo.org/|Flask]]. Here's a [[http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world|tutorial on making a blog with it]]. | ||
Line 13: | Line 13: | ||
* [[http://docopt.org/|docopt]] for a stupidly easy and correct command-line interface description language. | * [[http://docopt.org/|docopt]] for a stupidly easy and correct command-line interface description language. | ||
* [[http://stevenloria.com/python-best-practice-patterns-by-vladimir-keleshev-notes/|Best practices]] by Vladimir Keleshev. | * [[http://stevenloria.com/python-best-practice-patterns-by-vladimir-keleshev-notes/|Best practices]] by Vladimir Keleshev. | ||
- | * [[https://twitter.com/brandon_rhodes/status/449938490516860928|You can ask a new-style class for its .__subclasses__()]] It uses weak references. Look at [[https://gist.github.com/etrepum/9862280|this interesting example with a child class inside a method]]. | + | * [[https://twitter.com/brandon_rhodes/status/449938490516860928|You can ask a new-style class for its .__subclasses__()]] It uses weak references. Look at [[https://gist.github.com/etrepum/9862280|this interesting example with a child class inside a method]]. |
+ | * A Power Point deck by Alex Martelli describing [[http://www.aleax.it/yt_pydi.pdf|Dependency Injection vs. Template Method (override base method) vs. Monkey Patching]]. | ||
+ | * [[http://stackoverflow.com/questions/101268/hidden-features-of-python|Hidden Features of Python]] at StackOverflow | ||
+ | * [[http://chriskiehl.com/article/parallelism-in-one-line|Parallelism in one line]] | ||
Would be nice to create a binary search in text files in Python. Maybe based on an answer deep in [[http://stackoverflow.com/questions/744256/reading-huge-file-in-python|Reading Huge File in Python]]. | Would be nice to create a binary search in text files in Python. Maybe based on an answer deep in [[http://stackoverflow.com/questions/744256/reading-huge-file-in-python|Reading Huge File in Python]]. | ||
Line 246: | Line 249: | ||
finally: | finally: | ||
fcntl.flock(f, fcntl.LOCK_UN) | fcntl.flock(f, fcntl.LOCK_UN) | ||
+ | </code> | ||
+ | |||
+ | ====== Fibonacci Generator with Itertools ====== | ||
+ | |||
+ | <code python> | ||
+ | import itertools | ||
+ | |||
+ | def fib(n): | ||
+ | """Print a Fibonacci series up to n.""" | ||
+ | a, b = 0, 1 | ||
+ | while True: | ||
+ | yield a | ||
+ | b = a + b | ||
+ | yield b | ||
+ | a = a + b | ||
+ | |||
+ | if __name__ == '__main__': | ||
+ | for x in itertools.islice(fib(), 5): | ||
+ | print x | ||
+ | |||
+ | # for i in range( 5 ): | ||
+ | # print i, fib( i ) | ||
</code> | </code> | ||