473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Learning Basics

So I've been studying python for a few months (it is my first foray
into computer programming) and decided to write my own little simple
journaling program. It's all pretty basic stuff but I decided that I'd
learn more from it if more experienced programmers could offer some
thoughts on how I could do things better.

#simple little journal

from time import asctime
myjournal=file('journal.txt','a+')

formatter="*"*80+"\n"
todaysdate=asctime()
myjournal.write(formatter)
myjournal.write(todaysdate + "\n\n")

loop="set"

while loop!=':a':
loop=raw_input(':')
if loop!=':a':
myjournal.write(loop+"\n")
if loopz==':a':
myjournal.close()

#end of stuff

So I'd appreciate some good feedback or ideas.

Jul 8 '07 #1
2 939
On Jul 8, 12:10 pm, Brad <deviantbunnyl...@gmail.comwrote:
So I've been studying python for a few months (it is my first foray
into computer programming) and decided to write my own little simple
journaling program. It's all pretty basic stuff but I decided that I'd
learn more from it if more experienced programmers could offer some
thoughts on how I could do things better.

#simple little journal

from time import asctime
myjournal=file('journal.txt','a+')

formatter="*"*80+"\n"
todaysdate=asctime()
myjournal.write(formatter)
myjournal.write(todaysdate + "\n\n")

loop="set"

while loop!=':a':
loop=raw_input(':')
if loop!=':a':
myjournal.write(loop+"\n")
if loopz==':a':
myjournal.close()

#end of stuff

So I'd appreciate some good feedback or ideas.
#!/usr/bin/env python

"""simple little journal"""

import sys
import time

EXIT_COMMAND = ':a'
HEADER = "*" * 80

def add_journal_entry(filename='journal.txt'):
"""
Prompt the user to enter text, and write it into the journal file.
"""
print "Enter your journal entry."
print "When done, type %r." % EXIT_COMMAND
journal_file = file(filename, 'a+')
journal_file.write(HEADER + "\n")
journal_file.write(time.asctime() + "\n\n")
while True:
line = raw_input(':')
if line == EXIT_COMMAND:
break
journal_file.write(line + "\n")
journal_file.close()

def _main(argv=None):
"""Executed when file is run as a script."""
if argv is None:
argv = sys.argv
if len(argv) == 1: # No filename specified; use the default
add_journal_entry()
else:
add_journal_entry(argv[1])

if __name__ == '__main__':
_main()

Jul 8 '07 #2
On Jul 8, 12:10 pm, Brad <deviantbunnyl...@gmail.comwrote:
So I'd appreciate some good feedback or ideas.
I addition to Dan's suggestions, you could add a Tk text entry box to
make it easier to enter text.

I can send you some code if you'd like, as Steve Holden just
generously helped me make a text entry box for my quote database. Or
you can make your own starting here:

Alan Gauld's "GUI Programming with Tkinter"
http://www.freenetpages.co.uk/hp/alan.gauld/tutgui.htm

These also came in very handy for cutting and pasting.

Jeff Eppler's clp post - 3 August 2005
cut and paste text between Tkinter widgets"
http://tinyurl.com/2d97gj

rd

Jul 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Jhon smith | last post by:
Hi,all,I was just wondering if I am likly to have any problems trying to learn C from older books,I have some from the late 80`s,mid/late 90`s. I am using Dev-C++ on the pc windows platform,But I...
90
by: Jhon smith | last post by:
Hi all,Just wondering are there any problems with learning c from older books,as I have picked up some from 1988,1994,1997,1998. By using books of this age(Im on a tight budget)am I going to...
25
by: Shawn Ferguson | last post by:
I'm in the process of learning .NET but I have an issue. How do you know what CAN exist. What I mean is how does a person know to use the string.todate or something like that? There are so many...
7
by: Max | last post by:
On monday I start a semester course in Python (the alternative was Java). I was looking through the course outline and noticed the following: 1) UserDict is used. This is deprecated, right? 2)...
26
by: mfasoccer | last post by:
I am sorry if this is an inappropriate place to put this post, if so please delete it. I am wondering about a few things. Do you guys recommend learning C as a second language, as someone who...
5
by: Amai | last post by:
I'm ineterested in learning ASP.NET, in conjunction with both C# and VB.NET. However, i don't really know where to start. Are there classes available at local colleges, or do i have to go...
78
by: arnuld | last post by:
hai all, i am standing on a "crossroad to C++". I am here in front of you as i have a problem. i will be brief. Please do not think: "arnuld is sick", i am really struggling & doing hard-work to...
7
by: Dick Moores | last post by:
In a couple of places recently I've seen Brent Welch's _Practical Programming in Tcl & Tk_ (<http://tinyurl.com/ynlk8b>) recommended for learning Tkinter well. So a couple of questions: 1) Is...
6
by: Rui Maciel | last post by:
Recently I woke up inclined to take up the task of learning another programming language. I've already dipped my toes in Perl (I've read online tutorials and wrote a couple of irrelevant pet...
16
by: John Salerno | last post by:
Just something that crosses my mind every time I delve into "Learning Python" each night. Does anyone see any value in learning Python when you don't need to for school, work, or any other reason?...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.