[[Python]]
 

Differences

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

Link to this comparison view

python:python [2013/09/28 00:55]
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.
 +  * [[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 16: Line 23:
  
 Would be good to experiment with [[http://pingswept.org/2009/01/24/least-squares-polynomial-fitting-in-python/|least-squares polynomial fitting in Python]]. Would be good to experiment with [[http://pingswept.org/2009/01/24/least-squares-polynomial-fitting-in-python/|least-squares polynomial fitting in Python]].
- 
 ===== Data Analysis ===== ===== Data Analysis =====
  
Line 226: Line 232:
  
     x = property( getx, setx )     x = property( getx, setx )
 +</code>
 +
 +====== filelock ======
 +
 +Evan Fosmark has a filelock module.  But here's a quick and dirty implementation of a lock that uses the current file:
 +
 +<code python>
 +import os
 +import fcntl
 +import inspect
 +# Maybe use os.path.abspath(__file__) ?
 +with open(os.path.abspath inspect.getfile(inspect.currentframe())), 'r') as f:
 +    try:
 +        fcntl.flock(f, fcntl.LOCK_EX)
 +        call_that_cannot_be_concurrent()
 +    finally:
 +        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.1380354915.txt.gz · Last modified: 2013/09/28 00:55 by dblume
 
Recent changes RSS feed Driven by DokuWiki