This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
python:python [2013/11/15 09:48] dblume [Python] |
python:python [2022/06/15 07:49] (current) dblume Mention flask gunicorn nginx |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Python ====== | + | ====== |
| Man, there' | Man, there' | ||
| Line 7: | Line 7: | ||
| * [[http:// | * [[http:// | ||
| * [[http:// | * [[http:// | ||
| - | * Of course, there' | + | * Of course, there' |
| * There' | * There' | ||
| - | * Look into the microframework [[http:// | + | * Look into the microframework [[http:// |
| * [[https:// | * [[https:// | ||
| * [[http:// | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | * A Power Point deck by Alex Martelli describing [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| Would be nice to create a binary search in text files in Python. | Would be nice to create a binary search in text files in Python. | ||
| Line 227: | Line 232: | ||
| x = property( getx, setx ) | x = property( getx, setx ) | ||
| + | </ | ||
| + | |||
| + | ====== filelock ====== | ||
| + | |||
| + | Evan Fosmark has a filelock module. | ||
| + | |||
| + | <code python> | ||
| + | import os | ||
| + | import fcntl | ||
| + | import inspect | ||
| + | # Maybe use os.path.abspath(__file__) ? | ||
| + | with open(os.path.abspath inspect.getfile(inspect.currentframe())), | ||
| + | try: | ||
| + | fcntl.flock(f, | ||
| + | call_that_cannot_be_concurrent() | ||
| + | finally: | ||
| + | fcntl.flock(f, | ||
| + | </ | ||
| + | |||
| + | ====== Various Approaches to threaded URL Requests ====== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * Or, use the doc's [[https:// | ||
| + | * And, as mentioned in Parallelism in One Line, [[https:// | ||
| + | |||
| + | ====== Fibonacci Generator with Itertools ====== | ||
| + | |||
| + | <code python> | ||
| + | import itertools | ||
| + | |||
| + | def fib(n): | ||
| + | """ | ||
| + | a, b = 0, 1 | ||
| + | while True: | ||
| + | yield a | ||
| + | b = a + b | ||
| + | yield b | ||
| + | a = a + b | ||
| + | |||
| + | if __name__ == ' | ||
| + | for x in itertools.islice(fib(), | ||
| + | print x | ||
| + | |||
| + | # for i in range( 5 ): | ||
| + | # print i, fib( i ) | ||
| </ | </ | ||