Skip to content

Instantly share code, notes, and snippets.

View mike1026915's full-sized avatar

Mike Fang mike1026915

View GitHub Profile
@mike1026915
mike1026915 / sample.py
Last active May 13, 2017 12:42
Python class if
class Popen(object):
if mswindows:
def communicate(self):
"""
Windows implementation
"""
pass
else:
def communicate(self):
"""
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)
import unittest
class Test(unittest.TestCase):
def test_a(self):
print ("a")
def test_b(self):
print ("b")
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()