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
| -*- mode: compilation; default-directory: "~/git-repositories/work/ine-rackcontrol/rackcontrol/" -*- | |
| Compilation started at Tue Jul 21 15:36:15 | |
| ./clear_line.py --rack-name=c3rack25 --track=c3 | |
| [2015-07-21T15:36:15-0700.989 95733]: INFO [root][clear_line] (erichanchrow) I was invoked as './clear_line.py' '--rack-name=c3rack25' '--track=c3' | |
| [2015-07-21T15:36:15-0700.989 95733]: INFO [root][clear_line] my parent's PID is 42607 (?? [Errno 2] No such file or directory: '/proc/42607/cmdline' ??) | |
| [2015-07-21T15:36:15-0700.989 95733]: INFO [__main__][clear_line] You passed access_server_ip_address | |
| [2015-07-21T15:36:15-0700.989 95733]: INFO [__main__][clear_line] Hello from clear_all_lines_on_rack c3rack25 c3 | |
| [2015-07-21T15:36:15-0700.989 95733]: INFO [__main__][clear_line] Track 'c3' is not 'dc', so doing bulk_clear_lines instead of _clear_via_telnet_gateway | |
| [2015-07-21T15:36:16-0700.031 95733]: INFO [__main__][clear_line] <itertools._grouper object at 0x105671990> => (None, u'10.4.204.91'); no alt_ip => I hit |
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 os | |
| import requests | |
| def POST_in_background(data): | |
| child = os.fork() | |
| if child: | |
| return | |
| requests.post(data) | |
| exit(0) |
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
| >>> (False and False) or True | |
| True | |
| >>> False and (False or True) | |
| False | |
| >>> False and False or True | |
| True | |
| >>> |
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
| class Cat(object): | |
| def __init__(self): | |
| self.tummy = [] | |
| def eat(self, thing): | |
| self.tummy.append(thing) | |
| def hairball(self): | |
| print("I puked up a {}".format(self.tummy.pop())) |
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 json | |
| l = [] | |
| l.append(1) | |
| l.append("cat") | |
| l.append("OK, enough for now") | |
| with open("list.json", 'w') as outf: | |
| json.dump(l, outf) |
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
| def returns_a_list(): | |
| return [1, 2, 3] | |
| l = returns_a_list() | |
| print(l) | |
| # python wat.py | |
| # [1, 2, 3] |
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
| last_status = object() | |
| for index, item in enumerate(sequence_with_three_things): | |
| if index == 2 and last_status == whatever: | |
| continue | |
| last_status = do_some_work() |
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
| last_status = object() | |
| for index, item in enumerate(sequence_with_three_things): | |
| if index == 2 and last_status == whatever: | |
| continue | |
| last_status = do_some_work() |
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
| (let ((thelist '(test 2))) | |
| (flet ((test (x) (+ x x))) | |
| (eval thelist))) | |
| 4 |
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
| Python 2.7.9 (default, Apr 1 2015, 18:18:03) | |
| [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> import timeit | |
| >>> timeit.timeit("print(1 + 2)", number=1) | |
| 3 | |
| 1.2159347534179688e-05 | |
| >>> |