This file contains 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 Popen(object): | |
if mswindows: | |
def communicate(self): | |
""" | |
Windows implementation | |
""" | |
pass | |
else: | |
def communicate(self): | |
""" |
This file contains 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 threading | |
n = 0 | |
def add_one(): | |
global n | |
n += 1 | |
def fun(m): | |
threads = [] | |
for i in range(m): | |
t = threading.Thread(target=add_one) |
This file contains 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 unittest | |
class Test(unittest.TestCase): | |
def test_a(self): | |
print ("a") | |
def test_b(self): | |
print ("b") |
This file contains 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 sys | |
class Tee(object): | |
def __init__(file_name, mode): | |
self._file = open(file_name, mode) | |
def __enter__(self): | |
return self | |
def __exit__(self): | |
self.__close() |