def format(n): n = float(n) millidx = max( 0, min( len(millnames) - 1, int(math.floor(0 if n == 0 else math.log10(abs(n)) / 3)))) return '{:.0f}{}'.format(n / 10**(3 * millidx), millnames[millidx]) b = country(country="The UK", population=format(63230000)) appl_tmpl = Template(doc["container-1"]) appl_tmpl.render(country=b['country'], population=b['population']) def country(name, climate, population, capital): return { 'name': name, 'climate': climate, 'population': population, 'capital': capital } b = country(name="The UK", climate={ 'temperature': 'cold', 'rainfall': 'excess'
output_window.style.display = "block" output.text = "" try: exec(editor.text) finally: sys.stdout = save_stdout sys.stderr = save_stderr width = window.innerWidth height = window.innerHeight tmpl = Template("content", [run, load, save, save_as, delete, size_up, size_down]) tmpl.render(editor_height=int(0.9 * height), height=int(0.6 * height), width=int(0.6 * width), top=int(0.2 * height), left=int(0.2 * width)) Template("dialog_window").render( height=int(0.6 * height), width=int(0.6 * width), top=int(0.2 * height), left=int(0.2 * width)) dialog = document["dialog"] filebrowser = document["filebrowser"] scripts = [] open_scripts = [] def close_window(evt): button = evt.target w = button.closest("div")
change format according to the result """ num = num * quant if num < 1: num = 100 * num return '{0}p'.format(str(num)) else: num = round(num, 2) return '£{0}'.format(str(num)) app_tmpl = Template(doc["container-1"]) app_tmpl.render(item=item, price=price, quantity=quantity, product=product, total=formate(price, quantity)) def update_value(ev, elt): """ update new value """ global product if ev.target.value == "banane": item = product[1][0] price = product[1][1] quantity = product[1][2] elif ev.target.value == "orange": item = product[2][0]