def avg_vix_roc(self): list = [] for i in range(22, 1, -1): list.append(self.vix_roc(i)) df = DataFrame(list, columns=["AVG ROCS"]) df["AVG"] = df.ewm(span=21)["AVG ROCS"].mean() df = df.tail(1) df = df.iloc[:, -1] df = float(df.to_string(index=False)) return df
def factorial(x): if int(x) - x > 0: print "Not an integer!" elif int(x) - x < 0: return "Not an integer!" else: list = [] while x != 0: list.append(x) x -= 1 y = reduce(lambda x, y: x*y, list) return y print y
def html_htm_data(self): #自合链接内容 try: #self.nl_link_int=4 ;内链多少条 #self.wl_link_int=2 ;外链多少条 list = [] a = [ "<li><a href=\"$url\">$key</a></li>", "<A href=\"$url\" target='_blank'>$key</A>", "<a href=\"$url\" target=\"_blank\">$key</a>", "<li><a href=\"$url\">$key</a></li>", "<A href=\"$url\" target='_blank'>$key</A>", "<a href=\"$url\" target=\"_blank\">$key</a>" ] # print self.nl_link_int # print self.wl_link_int #random.shuffle(a) #打算数组原有排序方式 url_data = a[self.sjs_random(0, len(a) - 1)] url_data = url_data.replace('$url', self.path_data) url_data = url_data.replace( '$key', self.key[self.sjs_random(0, len(self.key))]) list.append(url_data) url_data = a[self.sjs_random(0, len(a) - 1)] url_data = url_data.replace('$url', self.path_data + "index.html") url_data = url_data.replace( '$key', self.key[self.sjs_random(0, len(self.key))]) list.append(url_data) for i in range(self.wl_link_int): #外链 ss = self.link[self.sjs_random(0, len(self.link))] ss = ss.split("|") if len(ss) != 2: continue #跳过 这一次 #random.shuffle(a) #打算数组原有排序方式 url_data = a[self.sjs_random(0, len(a) - 1)] url_data = url_data.replace('$url', ss[0]) url_data = url_data.replace('$key', ss[1]) list.append(url_data) for i in range(self.nl_link_int): #内链 ss = self.url_lis[self.sjs_random(0, len(self.url_lis))] ss = ss.split("|") if len(ss) != 2: continue #跳过 这一次 #random.shuffle(a) #打算数组原有排序方式 url_data = a[self.sjs_random(0, len(a) - 1)] url_data = url_data.replace('$url', ss[0]) url_data = url_data.replace('$key', ss[1]) list.append(url_data) random.shuffle(list) #打算数组原有排序方式 url_data2 = "" for i in list: url_data2 += str(i) url_data2 += "\r\n" return self.htm_html_text.replace('$data_link', url_data2) except Exception, e: #print e return ""
def __init__(self, ftype, numElements): self.ftype = ftype self.numElements = numElements if ftype == UAVObjectField.FType.FLOAT32: if numElements == 1: self.value = 0.0 else: self.value = [] for n in range(0, numElements): append(self.value, 0.0) else: if numElements == 1: self.value = 0 else: self.value = [] for n in range(0, numElements): append(self.value, 0)
# This file is Copyright 2003 Dean Hall. # # This file is part of the Python-on-a-Chip program. # Python-on-a-Chip is free software: you can redistribute it and/or modify # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. # # Python-on-a-Chip is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 # is seen in the file COPYING up one directory from this. # # System Test 142 # list.append left a remnant on the stack # import list l = [] rv = list.append(l, 42) assert rv == None
def addField(self, field): append(self.fields, field)
print dict.keys(d) print dict.values(d) dict.clear(d) print d d['new'] = "more" print d print "d has key 'new' = ", dict.has_key(d, 'new') print "d has key 'old' = ", dict.has_key(d, 'old') # Tests for list if 1: foo = [0] list.append(foo, 1) print foo list.extend(foo, [2, 2]) print foo print list.count(foo, 1) print list.count(foo, 2) print list.count(foo, 42) print list.index(foo, 0) list.insert(foo, 0, "zero") list.insert(foo, -1, "penultimate") print foo
# Print statements end up in the log print "MoPync - bringing the Guido goodness to the world of MoSync" LOGO_HANDLE = 1 logo_width, logo_height = maGetImageSize(LOGO_HANDLE) screen_width, screen_height = maGetScrSize() background_color = 0x330055 # Create some random rectangles rectangles = [] for _ in xrange(10): list.append(rectangles, [rand() % screen_width, rand() % screen_height, rand() % 40 + 20, rand() % 40 + 20, (rand() % 0x40) * 0x10002 + 0x883388, rand() % 7 - 3, rand() % 7 - 3]) # Clear screen maSetColor(background_color) maFillRect(0, 0, screen_width, screen_height) keep_going = True while keep_going: sys.gc() # Wait for an event, or 20 ms maWait(1) # Handle all events from the event queue for event in maGetEvents():
# This file is Copyright 2010 Dean Hall. # # This file is part of the Python-on-a-Chip program. # Python-on-a-Chip is free software: you can redistribute it and/or modify # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. # # Python-on-a-Chip is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 # is seen in the file COPYING up one directory from this. # # System Test 235 # import list l = [] for i in xrange(3): print i list.append(l, i) assert l == range(3) # Results in an AssertionError because the generator's StopIteration is # not caught; there is no SETUP_LOOP bytecode for this code # [x/2. for x in xrange(10) if x%2 == 0]
# Print statements end up in the log print "MoPync - bringing the Guido goodness to the world of MoSync" LOGO_HANDLE = 1 logo_width, logo_height = maGetImageSize(LOGO_HANDLE) screen_width, screen_height = maGetScrSize() background_color = 0x330055 # Create some random rectangles rectangles = [] for _ in xrange(10): list.append(rectangles, [ rand() % screen_width, rand() % screen_height, rand() % 40 + 20, rand() % 40 + 20, (rand() % 0x40) * 0x10002 + 0x883388, rand() % 7 - 3, rand() % 7 - 3 ]) # Clear screen maSetColor(background_color) maFillRect(0, 0, screen_width, screen_height) keep_going = True while keep_going: sys.gc() # Wait for an event, or 20 ms maWait(1) # Handle all events from the event queue
# This file is Copyright 2003 Dean Hall. # # This file is part of the Python-on-a-Chip program. # Python-on-a-Chip is free software: you can redistribute it and/or modify # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. # # Python-on-a-Chip is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 # is seen in the file COPYING up one directory from this. # # System Test 142 # list.append left a remnant on the stack # import list l=[] rv = list.append(l, 42) assert rv == None