[Tutor] Creating To Do List Program - Question
Steven D'Aprano
steve at pearwood.info
Tue Oct 1 03:25:59 CEST 2013
On Mon, Sep 30, 2013 at 12:43:57AM +0100, Alan Gauld wrote:
> On 29/09/13 21:42, Rafael Knuth wrote:
>
> >iteration. I know my program is super cheesy & primitive, but I don’t
> >care, it does what I expect it to do,
>
> Really? You wrote a program that printed out a different
> program to the one you ran and that's what you wanted?
> It doesn't do anything about creating a ToDo list.
> It doesn't even bring you any closer to creating a ToDo list.
Ah, no I think I see what Rafael is trying to do! I remember those old
BASIC listings from the 1970s where the first thing the program did was
print out a page and a half of introductory text telling you what the
program did and what commands to give to operate it. I reckon that's
what he is doing.
> >Welcome World's Most Geeky To Do List Program
I don't think that word "Geeky" means what you think it means. It
doesn't mean "incomplete". It's a bit much to claim the crown of World's
Most Geeky program when you haven't actually written the program yet.
That's like announcing that you are now Boxing Heavyweight Champion of
the World after ordering a pair of boxing gloves online.
> >G E E K L I S T 1 . 0
> >
> >If you want to add items to the list, enter:
> >
> >text_file = open("ToDoList.txt", "w")
> >text_file.write("add your item here ")
> >text_file.write("add action item here ")
> >text_file.write("you get the point, right?")
> >text_file.close()
And quite frankly, this is a rubbish to-do-list program. It relies on
the user *writing the code for you*. A better design would be something
like this:
open "ToDoList.txt"
print first three items
print last item
add "wash car"
add "feed the cat"
save
add "return book to library"
save
remove item 2
print items 5-20
remove items 3-12, 17
save
print all items
Now that would be a cool todo list program that people could use! And an
excellent programming challenge. It would require you to learn about
reading and writing files, keeping information in memory, using a REPL
(Read/Eval/Print Loop), and writing a parser for human-readable
commands. Now *that's* geeky!
--
Steven
More information about the Tutor
mailing list