[Baypiggies] Fwd: code down sizing
Shannon -jj Behrens
jjinux at gmail.com
Sat Sep 2 02:43:40 CEST 2006
I couldn't figure out why everyone kept saying the same things I did
until I realized I forgot to CC the list:
---------- Forwarded message ----------
From: Shannon -jj Behrens <jjinux at gmail.com>
Date: Sep 1, 2006 2:26 PM
Subject: Re: [Baypiggies] code down sizing
To: Brain Murphy <brianomorchoe at yahoo.co.uk>
Here are some ideas:
* Consolidate multiple prints into a single print:
print """\
hi
there"""
* Use dynamic imports (i.e. __import__).
* Use the cmd module.
-jj
On 9/1/06, Brain Murphy <brianomorchoe at yahoo.co.uk> wrote:
>
> I am having problems down sizing my code. My parents asked me to make a
> program were they can go into and find the recipe that they are looking for,
> and it will tell them the issue it is in.
>
> My code is huge and I have not been able to make it smaller
> <<<
> def print_options():
> print " Cover Recipes"
> print "Options"
> print "'P' Print options"
> print " please chose a-z corresponding with the recipe name you are
> looking for."
> print "'B' capital B to go back"
> choice = "P"
> while choice !="B":
> if choice == "a":
> import a
> elif choice == "b":
> print "No recipes were found that start with B"
> elif choice == "c":
> import c
> ........................
> elif choice == "z":
> print "No recipes were found that start with Z"
> elif choice != "B":
> print_options()
> choice = raw_input("Enter choice: ")>>>
>
> as you can see it is huge for its size, I know it can be smaller like
> choice = raw_input("Enter letter:%") for % in %'s list
> list = az-aZ-AZ
> if choice in list = % import %
>
> or something along those lines but I can not figure it out. Can any one help
> me with this?
> Brian
>
>
>
>
>
> ________________________________
> The all-new Yahoo! Mail goes wherever you go - free your email address from
> your Internet provider.
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> http://mail.python.org/mailman/listinfo/baypiggies
>
>
>
More information about the Baypiggies
mailing list