[[Python]]
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

python:python [2014/01/22 15:28]
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]].
   * [[https://dataset.readthedocs.org/en/latest/|dataset]], an abstraction layer above relational databases.   * [[https://dataset.readthedocs.org/en/latest/|dataset]], an abstraction layer above relational databases.
   * [[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.
 +  * [[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 238: Line 243:
 import inspect import inspect
 # Maybe use os.path.abspath(__file__) ? # Maybe use os.path.abspath(__file__) ?
-with open( os.path.abspathinspect.getfile( inspect.currentframe() ) ), 'r' ) as f:+with open(os.path.abspath inspect.getfile(inspect.currentframe())), 'r') as f:
     try:     try:
-        fcntl.flock( f, fcntl.LOCK_EX )+        fcntl.flock(f, fcntl.LOCK_EX)
         call_that_cannot_be_concurrent()         call_that_cannot_be_concurrent()
     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>
  
python/python.1390433328.txt.gz · Last modified: 2014/01/22 15:28 (external edit)
 
Recent changes RSS feed Driven by DokuWiki