The following transcripts were recorded during human - computer interaction.
Programmer: okay, give me the numbers one by one.
Computer: I don't know how to "by" "one" and "one".
P: what? Just... is there a number at the top left of the page?
| class TrackingDict(dict): | |
| instances = [] | |
| def __init__(self, dct): | |
| super(TrackingDict, self).__init__(dct) | |
| self.used_keys = [] | |
| TrackingDict.instances.append(self) |
| import types, time, functools | |
| from twisted.internet import reactor, protocol, threads | |
| # --- | |
| def async(func): | |
| def wrapper(*args, **kwargs): |
| # SETTING DEFAULT | |
| sysctl -w net.ipv4.ip_local_port_range="500 65535" # 32768 61000 | |
| sysctl -w net.ipv4.tcp_tw_recycle="1" # 0 | |
| sysctl -w net.ipv4.tcp_tw_reuse="1" # 0 | |
| sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216" # 4096 87380 6291456 | |
| sysctl -w net.ipv4.tcp_wmem="4096 16384 16777216" # 4096 16384 4194304 | |
| sysctl -w fs.file-max="655300" # 797108 | |
| sysctl -w fs.nr_open="3000000" # 1048576 |
| #!/usr/bin/env python | |
| import os, sys, shutil | |
| FROM_TO = ( | |
| ('/origin/dir/1', '/destination/dir/1'), | |
| ('/origin/dir/2', '/destination/dir/2'), | |
| ('/origin/dir/3', '/destination/dir/3') | |
| # ... | |
| ) |
| def init(): | |
| # This wrapper avoids global scope contamination | |
| import os, sys, atexit, readline, rlcompleter, pprint, glob | |
| # Enable auto-complete: | |
| readline.parse_and_bind("tab: complete") | |
| # Save command history: | |
| history_path = os.path.expanduser("~/.pyhistory") |
| # Dummy | |
| class Redis: | |
| def send(self, method, key, args, f): | |
| print method, key, args, f | |
| class Nest(str): | |
| def __init__(self, key, redis = Redis()): | |
| super(Nest, self).__init__(key) |
| class OrderFilterForm(Form): | |
| name = CharField(required = False) | |
| email = CharField(required = False) | |
| aec = CharField(required = False) | |
| date_created_from = DateField(required = False) | |
| date_created_to = DateField(required = False) | |
| def process(self): | |
| data = lambda key: self.cleaned_data.get(key, '') |
| # ============================================================================ # | |
| # Bienvenido al país de Python! Acá todos hablan python, idioma del que vos por | |
| # ahí no sabés nada. Pero no te preocupes: con esta guía vas a dominar las | |
| # frases más comunes en un toque. | |
| # Lo primero que tenés que entender es que las frases que empiezan con un '#' | |
| # (numeral) son totalmente ignoradas en python. O sea que esta conversación que | |
| # estamos teniendo es completamente privada: nadie en Python se está enterando. |
| // Asssignment: | |
| a = b = c; | |
| if (status = result()); | |
| // Standard setters: | |
| setA(setB(c)); // No. Setters return void. | |
| if (setStatus(result()); // And again. Impossible. |