A basic program which writes the user name who has logged in the windows machine:
######################
# User info #
######################
import os
import datetime
from time import strftime
def foo():
usr_log = os.environ ['USERNAME']
sys_log = os.environ ['USERPROFILE']
current_time = strftime("%a, %d %b %Y %H:%M:%S")
dt_str = str (datetime.date.today())
filename = usr_log + '_' + dt_str + '.' + 'txt'
write_line= "File created by %s on %s" % (usr_log, current_time)
write_line1 = "The default path is %s" % sys_log
file = open(filename, 'w')
file.truncate()
file.write('%s\n %s\n'% (write_line, write_line1))
foo()