One of the many things I did when updating the general toolbox to vPro2A was to keep a running script that vetted the syntax of the functions I list in “Useful Module Functions”. Some of these took a little head scratching but in the code below everything works (on a windows machine) like a charm. Here it is for you to try for yourself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #test TB1 Module Functions: #MATH import math x = 10.2 y = 10.5 z = 10.8 shorttup = (x,y,z) #ceil - smallest integer > variable value print (math.ceil(x),math.ceil(y), math.ceil(z)) #fsum - floating point sum of an iterable print (math.fsum(shorttup)) #sqrt - square root print (math.sqrt( 144 )) #log print ( "natural: " , math.log( 100 )) print ( "base 10: " , math.log( 100 , 10 )) #constants: pi and e print (math.pi, math.e) #factorial print (math.factorial( 7 )) #RANDOM import random #seed() random.seed() # used first with seed causes repeatable events #choice() myseq = ( 56 , 9 , 1 , 212 , 31 , 42 ) print (random.choice(myseq)) print (random.choice(myseq)) print (random.choice(myseq)) #randomint(start,end) print ( "randint: " ,random.randint( 1 , 100 )) #random() print ( "random float 0-1: " , random.random()) print ( "random float 0-1: " , random.random()) print ( "random float 0-1: " , random.random()) #SYS import sys #path print (sys.path) #platform print (sys.platform) #DATETIME from datetime import * #note: import datetime does not work for some functions dtetoday = date.today() print ( "date.today(): " , dtetoday) dtup = date.timetuple(dtetoday) print (dtup) print ( "datetime.today: " ,datetime.today()) print ( "datetime.now: " ,datetime.now()) #TIME import time #note: from time import * does not work for some functions #localtime mytime = time.localtime() print ( "localtime printed by asctime: " ,time.asctime(mytime)) print ( "date.today() time printed by asctime: " , time.asctime(dtup)) #clock print ( "time.clock: " ,time.clock()) #sleep print ( "sleeping 5 seconds - bye" ) time.sleep( 3 ) print ( "...zzzzz...." ) time.sleep( 2 ) print ( "all done, back in action" ) #CALENDAR import calendar mymo = calendar.TextCalendar() mymo.setfirstweekday(calendar.SUNDAY) mymo.prmonth( 2018 , 7 ) |