Advise of programming one of my first programs
Anatoli Hristov
tolidtm at gmail.com
Wed Mar 28 18:33:54 EDT 2012
> You are correct it is not. :) You code is overly complex making it harder
> to understand. Try and reduce the problem to the least number of tasks you
> need.
> >From the Zen of Python, "Simple is better than complex." It is a good
> programming
> mentality.
Complex is better than complicated. :p
> 2. A system to navigate your program.
> def mmenu():
> # load tbook here
> while True:
> choicem = get_menu_choice()
> if choicem == 'e' or choicem == 'E':
> book = get_book_name()
> edit( tbook, book )
> elif choicem == 'd' or choicem == 'D':
> book = get_book_name()
> details( tbook, book )
> elif choicem =='Q' or choicem == 'q':
> break # end loop to exit program
> else:
> print 'Selection {0} not understood.'.format( choicem )I have
> given you more functions
With the main navigation menu I will only have the option to select a
nickname and when a nickname is selected then it loads Details of the
contact and from loaded details I can choice Edit or back to main screen,
like I did it the first time, or else I can do it => when 'e' pressed to
ask for a nickname and then edit it.
> 3. function to write an edited book
> def write_book(tbook):
> write_book = open('c:/Python27/Toli/myfile.txt', 'w')
> write_book.write(str(tbook))
> # I think repr would be more accurate than str here.
>
I`m not that far as you already know :) I hope I will learn everything as
soon as I can as I`m not capable to read python everyday.
> I do not think you need any other functions. Now you just need to finsh
> all the functions
> and put it all together.
>
I will finish it just need to understand more the functions and complex
arguments.
Thanks
Anatoli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120329/89d64f78/attachment-0001.html>
More information about the Python-list
mailing list