[Tutor] Creating To Do List Program - Question
Joel Goldstick
joel.goldstick at gmail.com
Sun Sep 29 23:09:34 CEST 2013
On Sun, Sep 29, 2013 at 4:42 PM, Rafael Knuth <rafael.knuth at gmail.com>wrote:
> Hej there,
>
> I am writing a to do list program in Python 3.0.
>
> Earlier this week, I shared my first iteration on the mailing list,
> and the feedback was that I should learn how to create, write to and
> read from a text file – which I did. Below please find my second
> iteration. I know my program is super cheesy & primitive, but I don’t
> care, it does what I expect it to do, and I will improve it in further
> iteration cycles. As of now, I want to understand how I can add
> further functionalities to my program such as: appending items to the
> list, removing and replacing items. Can anyone help? Thank you very
> much in advance!
>
> print("""
>
> Welcome World's Most Geeky To Do List Program
>
> 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()
>
> If you want to print your to do list, enter:
>
> text_file = open("ToDoList.txt", "r")
> print(text_file.read())
> text_file.close()
>
> We are constantly improving our program, watch out for version 2.0!
>
> """)
>
I applaud your efforts, but I don't think that code does what you think it
does. First, the whole code block is triple quoted so it will print out as
is. None of the statements in it will run at all. I'm guessing you want
to print instructions asking the user to type something to indicate what
they want to do.
So, I suggest you write some code to open a file, write some stuff to it.
Close it, then open it to read and print the results. That will get you
going on basic file stuff.
It looks like what you want to do might actually be easier to do with a
database. That adds to your list of things to learn, but in the end you
will have a useful companion skill and much simpler code than what you need
if you stick with a text file.
mysql comes with python, and you can learn the basics over a weekend using
the interactive tool that comes with it.
_______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130929/7ff8ad55/attachment.html>
More information about the Tutor
mailing list