#! /usr/bin/python
import time
x = 0
last = time.time()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import threading | |
""" Create a thread listening for client connections and enter the GUI mainloop | |
""" | |
def main(): | |
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server_socket.bind((socket.gethostname(), 80)) | |
server_socket.listen(5) | |
client_sockets = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENVIRONMENT VARIABLES | |
The following environment variables could affect ps: | |
COLUMNS | |
Override default display width. | |
LINES | |
Override default display height. | |
PS_PERSONALITY |
greater_42 = (num for num in mylist if num > 42)
square = (num ** 2 for num in greater_42)
retval = 0
for num in square:
retval = 3 * retval + num
vs.
From the putc
man page, "putc()
is equivalent to fputc()
except that it may be implemented as a macro which evaluates stream more than once."
I wasn't sure what this meant so I asked Shevek.
He launched into a lambda calculus explanation that eventually boiled down to: putc
may evaluate it's arguments more than once, but fputc
evaluates them exactly once.
This is because putc
is implemented as a macro and the C preprocessor just does string substitution, leading to examples like the ones below.
Ignoring what putc
and fputc
actually do, let's look at a simplified version where they both simply do one operation twice and another operation once:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./test-driver.py | |
[******************************] 1000/1000 100% [00:10, 00:00, 98.88 #/s] | |
Traceback (most recent call last): | |
File "./test-driver.py", line 29, in <module> | |
for _ in tqdm(range(1000), leave=True, format_dict=format_dict1): | |
TypeError: tqdm() got an unexpected keyword argument 'format_dict' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
class Player() | |
_count = itertools.count() | |
def __init__(self): | |
self.id = _count.next() | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Comments! | |
PROGRAM joel IS | |
VARIABLE movecounter = 4 | |
INSTRUCTION default IS | |
IF next-is-not-friend THEN | |
infect | |
END IF | |
WHILE next-is-empty DO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17:04:49 D, [2013-08-08T17:04:48.397029 #22915] DEBUG -- : error in setup command: Error parsing /tmp/buildd/python-cinderclient-1.0.5/setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. | |
17:04:49 D, [2013-08-08T17:04:48.418053 #22915] DEBUG -- : dh_auto_clean: python setup.py clean -a returned exit code 1 | |
17:04:49 D, [2013-08-08T17:04:48.419824 #22915] DEBUG -- : make: *** [clean] Error 1 |
>>> for index, letter in enumerate('foobar'):
... print index, letter
...
0 f
1 o
2 o
3 b
4 a
NewerOlder