def sonTest(do): name = 'son demo' print "this is son function; name : %s " % name print "local son function globals and locals " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals())
def test(name): info = 'hello world' def sonTest(do): name = 'son demo' print "this is son function; name : %s " % name print "local son function globals and locals " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) sonTest(info) print "-------------- local test function globals and locals -------------- " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) return None
fLog.write("no txns this month\n") fLog.close() return None fLog.write("-------------------begin--------------------\n") dataArr = fAccount.readlines() fAccount.close() totalAccount = 0 for line in dataArr: tmpAccount = set_float(line) if isinstance(tmpAccount, float): totalAccount += tmpAccount fLog.write("add acount %s \n" % tmpAccount) else: fLog.write("ingore %s \n" % tmpAccount) fLog.close() print "total money is : %.2f " % tmpAccount return None checkAmount() try: raise TypeError, ('has error ', 12) with open('../../data/amount.json.demos1', 'r') as f: CollectionHelper.printEx(f.readlines()) except (IOError, TypeError), e: print "has error %s " % str(e) print "*" * 88 assert 1 == 2
# /usr/bin/env python # encoding:utf8 import threading import time from time import sleep, ctime import sys import os sys.path.insert(1, os.path.realpath('..')) from utils.CollectionHelper import CollectionHelper print "-" * 88 CollectionHelper.printEx(sys.modules) print CollectionHelper.getMaxDeepth() def now(): return str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) class myThread (threading.Thread): """docstring for myThread""" def __init__(self, nloop, nsec): super(myThread, self).__init__() self.nloop = nloop self.nsec = nsec def run(self): print 'start loop', self.nloop, 'at:', ctime()
#!/usr/bin/env python # encoding:utf8 import sys import os import feedparser sys.path.insert(1, os.path.realpath('..')) from utils.CollectionHelper import CollectionHelper # from future import Future python_wiki_rss_url = "http://www.python.org/cgi-bin/moinmoin/" \ "RecentChanges?action=rss_rc" feed = feedparser.parse(python_wiki_rss_url) print "-" * 88 CollectionHelper.printEx(feed) print CollectionHelper.getMaxDeepth() # hit_list = [ "http://...", "...", "..." ] # list of feeds to pull down # pull down all feeds # future_calls = [Future(feedparser.parse,rss_url) for rss_url in hit_list] # block until they are all in # feeds = [future_obj() for future_obj in future_calls] # t = raw_input('hellow')
print "local son function globals and locals " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) sonTest(info) print "-------------- local test function globals and locals -------------- " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) return None test(name) print "-------------- top globals and locals -------------- " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) print "*" * 88 # import os.path as path # print help(path) # from os import path # print dir(path) t = __import__("utils.CollectionHelper", globals(), locals(), ['CollectionHelper']) print help(t) print t.__file__
# /usr/bin/env python # encoding:utf8 import threading import time from time import sleep, ctime import sys import os sys.path.insert(1, os.path.realpath('..')) from utils.CollectionHelper import CollectionHelper print "-" * 88 CollectionHelper.printEx(sys.modules) print CollectionHelper.getMaxDeepth() def now(): return str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) class myThread(threading.Thread): """docstring for myThread""" def __init__(self, nloop, nsec): super(myThread, self).__init__() self.nloop = nloop self.nsec = nsec def run(self): print 'start loop', self.nloop, 'at:', ctime() sleep(self.nsec) print 'loop', self.nloop, 'done at:', ctime()
print "this is son function; name : %s " % name print "local son function globals and locals " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) sonTest(info) print "-------------- local test function globals and locals -------------- " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) return None test(name) print "-------------- top globals and locals -------------- " CollectionHelper.printEx(globals()) print "*" * 22 + "local" + "*" * 22 CollectionHelper.printEx(locals()) print "*" * 88 # import os.path as path # print help(path) # from os import path # print dir(path) t = __import__("utils.CollectionHelper", globals(), locals(), ['CollectionHelper']) print help(t) print t.__file__
return None fLog.write("-------------------begin--------------------\n") dataArr = fAccount.readlines() fAccount.close() totalAccount = 0 for line in dataArr: tmpAccount = set_float(line) if isinstance(tmpAccount, float): totalAccount += tmpAccount fLog.write("add acount %s \n" % tmpAccount) else: fLog.write("ingore %s \n" % tmpAccount) fLog.close() print "total money is : %.2f " % tmpAccount return None checkAmount() try: raise TypeError, ('has error ', 12) with open('../../data/amount.json.demos1', 'r') as f: CollectionHelper.printEx(f.readlines()) except (IOError, TypeError), e: print "has error %s " % str(e) print "*" * 88 assert 1 == 2