python with open invalid argument windows -


import datetime import os import sys import time  if "zlog_file" not in globals():     global zlog_file     script_dir = os.path.realpath(sys.argv[0]).replace(sys.argv[0], "")     zlog_file = os.path.join(script_dir, "log", datetime.datetime.fromtimestamp(time.time()).strftime("%m-%d-%y %h:%m:%s"))     open(zlog_file, "w"):         pass  def log(level, msg):     open(zlog_file, "a") f:          # fix colors         if level == "info":             msg = "esc[37m[info] " + msg          elif level == "warn":             msg = "esc[33m[warn] " + msg          elif level == "error":             msg = "esc[31m[error] " + msg          if level != "error":             print(msg)         else:             sys.stderr.write(msg)         f.write(msg) 

i made simple logging library on first import makes new file current time , date in log directory in same location main script being run. following error however:

traceback (most recent call last):                                                 file "test.py", line 1, in <module>                                                import zlog                                                                    file "c:\users\zane\desktop\zlog.py", line 10, in <module>                         open(zlog_file, "w"):                                                   oserror: [errno 22] invalid argument: 'c:\\users\\zane\\desktop\\log\\09-12-2016  20:02:26'                                                                       

what doing wrong?

edit: got rid of script name script_dir variable, , fixed formatting on if statements. im still getting error though

windows cant use colons in file names, , forgot remove main script path once got directory in


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -