![]() |
|
[Python] Help define a function plz. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Help define a function plz. (/showthread.php?tid=4633889) |
Help define a function plz. - Impaired_ - Jan 12, 2015 So im trying to learn python, and i read xerotics thread and im trying to re write his log program using 3.4.1 i think i almost have it but i keep getting error saying log is not defined. Heres the code. Quote:def log(): any help please? (Jan 12, 2015 05:28 PM)Impaired_ Wrote: So im trying to learn python, and i read xerotics thread and im trying to re write his log program using 3.4.1 i think i almost have it but i keep getting error saying log is not defined. LMAO i got it. i had.. def log(): log name was Log() GG me. A new question, when it logs the input it just logs the sequence in the .txt file. f.write("\n\n"+"-"*25+"\nDay: "+day+"\nMonth: "+month+"\nYear: "+year+"\nNotes: "+notes+") f.close() Whats wrong here? please anyone? * - Ju1c3b0x - Jan 12, 2015 make sure you: file = open('file_name', w) #will create if nonexistent file.write("\n\n"+"-"*25+"\nDay: "+day+"\nMonth: "+month+"\nYear: "+year+"\nNotes: "+notes+") file.close() * - Impaired_ - Jan 13, 2015 (Jan 12, 2015 09:57 PM)Ju1c3b0x Wrote: make sure you: Thank you tremendously I will try it when I get home. In the f.write code, will that save files to the dedicated folder each time a new log is taken?? Thanks again. * - Ju1c3b0x - Jan 13, 2015 (Jan 13, 2015 06:15 AM)Impaired_ Wrote: Thank you tremendously I will try it when I get home. well if you put it in function like a update function Code def update():and then maybe have a Log function for when you take a new log and call the update function at the end of the Log function. Just quick thoughts. * - Impaired_ - Jan 13, 2015 Thank you so much for your input, you're awesome! I'm at work but ill give these a try when I get home!! I just don't want the previously logged info to be overwritten. I have big plans for this logger, I just don't know how to get it together. I've read tons about python but I'm more of a hands on learner. One more question, I had an idea of being able to embed an img from the input of the user into the .txt file, any idea on how I could go about that?? You don't have to write the code lol, just point me in the right direction :) * - Ju1c3b0x - Jan 13, 2015 (Jan 13, 2015 09:50 AM)Impaired_ Wrote: Thank you so much for your input, you're awesome! Not a problem, i'm happy to help. But as for embedding an image in a text file, i'm not quite sure. Might be better to just store the img file alone separately and call upon it with the data from the text file. It will appear as its all the same file. Maybe look into a GUI if your wanting to go long term on this project. Software development process if you get stuck: What (Analysis) How (Design) Do It (Implementation) Test (Testing and Debugging) Use (Operation or Deployment) Maintain (Refinement) * - Impaired_ - Jan 13, 2015 (Jan 13, 2015 10:47 AM)Ju1c3b0x Wrote: Not a problem, i'm happy to help. But as for embedding an image in a text file, i'm not quite sure. Might be better to just store the img file alone separately and call upon it with the data from the text file. It will appear as its all the same file. Ok awesome thanks again :). I plan on dabbling with the GUI after I get the program to actually work properly, last night I got stuck on line of code that's supposed to put user input into the .txt file, it just kept printing the code on the .txt file, not sure what's wrong with the code, but I'm using an old source so I'm guessing it's a translation issue. I have a new problem. So i got the program to create a folder, and i want it to save the .txt files in the folder instead of on my desktop. Anyone have any suggestions? Heres what i got so far. thanks. Quote:global x |