My problem is simple, is their a way to make a variable equal multiple numbers? Such as X = 5 through 10, and then the program makes x equal something random 5 through 10, or something similar.
2009/6/30 <tutor-requ...@python.org> > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. PYTHONPATH-corrected (Bob Rea) > 2. Re: Needing Help (Bob Rea) > 3. Re: PYTHONPATH-corrected (Steve Willoughby) > 4. Re: Needing Help (Wayne) > 5. Re: Needing Help (Bob Rea) > 6. Re: Needing Help (Marc Tompkins) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 30 Jun 2009 14:33:27 -0400 > From: Bob Rea <pet...@petard.us> > To: tutor@python.org > Subject: [Tutor] PYTHONPATH-corrected > Message-ID: <200906301433.27455.pet...@petard.us> > Content-Type: text/plain; charset="iso-8859-1" > > In working my way through the book on python, I am working > in directories for chapers. Now I am on modules, and some > are reused in later chapters. I have set up a directory for > the modules. How do I add it to my PYTHONPATH? > I can use sys.path.append but that only lasts for the > session. > > This is on a suse linux 10 box > > -- > Bob Rea > mailto:pet...@petard.us > http://www.petard.us > http://www.petard.us/blog > http://www.petard.us/gallery > > > ------------------------------ > > Message: 2 > Date: Tue, 30 Jun 2009 14:06:01 -0400 > From: Bob Rea <b...@telaugos.com> > To: tutor@python.org > Subject: Re: [Tutor] Needing Help > Message-ID: <200906301406.02104....@telaugos.com> > Content-Type: text/plain; charset="utf-8" > > On Tue June 30 2009 1:17 pm, vishwajeet singh > <dextrou...@gmail.com>wrote: > > You can put your script in pastebin > > http://python.pastebin.com/ > > <http://python.pastebin.com/>I don't think any one will > > mind you pasting code in mail but pastebin makes it > > easier to read > > I am making my way through _Making Use of Python_ by Rashi > Gupta. I am using Python 2.4.1 > > I have run into problems in a script, listed at > http://python.pastebin.com/m51bc3388 > > If I input my own name and dob, it works: > b...@gandalf:~/python/MakingUse/Chapter05> python code1.py > Enter your first name: Bob > Enter your last name: Rea > Enter your date of birth, mm-dd-yyyy: 03-05-1943 > You can chose one of the following login names: > 1. BobR > 2. BobR53 > 3. RBob43 > 4. BRea66 > > If I use the data listed in the book, it fails: > b...@gandalf:~/python/MakingUse/Chapter05> python code1.py > Enter your first name: Laura > Enter your last name: Jones > Enter your date of birth, mm-dd-yyyy: 12-24-1980 > You can chose one of the following login names: > 1. LauraJ > 2. LauraJ2412 > 3. JLaura80 > Traceback (most recent call last): > File "code1.py", line 67, in ? > fourth=fname[0]+lname+ age_func() > TypeError: cannot concatenate 'str' and 'NoneType' objects > > What is going on here? > > Bob Rea > pet...@petard.us > -- > Bob Rea > mailto:gapet...@stsams.org > http://www.petard.us > http://www.petard.us/blog > http://www.petard.us/gallery > > Where is Bill Stringfellow > now that we really need him? > > > ------------------------------ > > Message: 3 > Date: Tue, 30 Jun 2009 12:08:13 -0700 > From: Steve Willoughby <st...@alchemy.com> > To: Bob Rea <pet...@petard.us> > Cc: tutor@python.org > Subject: Re: [Tutor] PYTHONPATH-corrected > Message-ID: <20090630190813.ga65...@dragon.alchemy.com> > Content-Type: text/plain; charset=us-ascii > > On Tue, Jun 30, 2009 at 02:33:27PM -0400, Bob Rea wrote: > > In working my way through the book on python, I am working > > in directories for chapers. Now I am on modules, and some > > are reused in later chapters. I have set up a directory for > > the modules. How do I add it to my PYTHONPATH? > > I can use sys.path.append but that only lasts for the > > session. > > You set the variable in your system's environment, which is > platform-dependent. For Linux, you'd typically put a line > in your ~/.profile or ~/.cshrc or ~/.login or ~/.bashrc or > whatever your shell uses per your account set up. > > So, for example, in a bash/sh shell, you'd say: > > export PYTHONPATH="/path/to/my/modules" > > or for csh: > > setenv PYTHONPATH "/path/to/my/modules" > > Then starting the next time you log in, that will be set > in your environment for you. > > > This is on a suse linux 10 box > > > > -- > > Bob Rea > > mailto:pet...@petard.us > > http://www.petard.us > > http://www.petard.us/blog > > http://www.petard.us/gallery > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > -- > Steve Willoughby | Using billion-dollar satellites > st...@alchemy.com | to hunt for Tupperware. > > > ------------------------------ > > Message: 4 > Date: Tue, 30 Jun 2009 14:27:34 -0500 > From: Wayne <sri...@gmail.com> > To: Bob Rea <b...@telaugos.com> > Cc: tutor@python.org > Subject: Re: [Tutor] Needing Help > Message-ID: > <333efb450906301227u76274a83x53ef42fdae41f...@mail.gmail.com> > Content-Type: text/plain; charset="windows-1252" > > Oops, forgot my reply-to-all > > On Tue, Jun 30, 2009 at 2:20 PM, Wayne <sri...@gmail.com> wrote: > > > On Tue, Jun 30, 2009 at 1:06 PM, Bob Rea <b...@telaugos.com> wrote: > > > >> <snip> > >> If I input my own name and dob, it works: > >> b...@gandalf:~/python/MakingUse/Chapter05> python code1.py > >> Enter your first name: Bob > >> Enter your last name: Rea > >> Enter your date of birth, mm-dd-yyyy: 03-05-1943 > >> You can chose one of the following login names: > >> 1. BobR > >> 2. BobR53 > >> 3. RBob43 > >> 4. BRea66 > >> > >> If I use the data listed in the book, it fails: > >> b...@gandalf:~/python/MakingUse/Chapter05> python code1.py > >> Enter your first name: Laura > >> Enter your last name: Jones > >> Enter your date of birth, mm-dd-yyyy: 12-24-1980 > >> You can chose one of the following login names: > >> 1. LauraJ > >> 2. LauraJ2412 > >> 3. JLaura80 > >> Traceback (most recent call last): > >> File "code1.py", line 67, in ? > >> fourth=fname[0]+lname+ age_func() > >> TypeError: cannot concatenate 'str' and 'NoneType' objects > >> > >> What is going on here? > >> > > > > Well the first line after "Traceback" give you the line of code and the > > filename. Which happens to be code1.py line 67. > > > > TypeError is the type of error - specifically you tried to do something > > with incompatible types. In this case, adding together a string and > > NoneType. > > > > I'll do a little digging, but my guess is you have a problem with your > > age_func() not returning any value. > > > > HTH, > > Wayne > > > > I was correct:def age_func(): > age=cur_year-year-1 > if month<cur_month or (month==cur_month and day<cur_day): > age=age+1 > return str(age) > > What happens if month is > cur_month AND it's not my birthday? > > You don't return a value. But if you simply unindent the "return" value > then > it should fix it: > > def age_func(): > age=cur_year-year-1 > if month<cur_month or (month==cur_month and day<cur_day): > age=age+1 > return str(age) > > Now regardless of whether age is incremented, it will return a string. > HTH, > Wayne > -- > To be considered stupid and to be told so is more painful than being called > gluttonous, mendacious, violent, lascivious, lazy, cowardly: every > weakness, > every vice, has found its defenders, its rhetoric, its ennoblement and > exaltation, but stupidity hasn?t. - Primo Levi > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20090630/fe4ba054/attachment-0001.htm > > > > ------------------------------ > > Message: 5 > Date: Tue, 30 Jun 2009 15:27:17 -0400 > From: Bob Rea <b...@telaugos.com> > To: Wayne <sri...@gmail.com> > Cc: tutor@python.org > Subject: Re: [Tutor] Needing Help > Message-ID: <200906301527.20516....@telaugos.com> > Content-Type: text/plain; charset="utf-8" > > On Tue June 30 2009 3:20 pm, you wrote: > > On Tue, Jun 30, 2009 at 1:06 PM, Bob Rea > <b...@telaugos.com> wrote: > > > <snip> > > > If I input my own name and dob, it works: > > > b...@gandalf:~/python/MakingUse/Chapter05> python > > > code1.py Enter your first name: Bob > > > Enter your last name: Rea > > > Enter your date of birth, mm-dd-yyyy: 03-05-1943 > > > You can chose one of the following login names: > > > 1. BobR > > > 2. BobR53 > > > 3. RBob43 > > > 4. BRea66 > > > > > > If I use the data listed in the book, it fails: > > > b...@gandalf:~/python/MakingUse/Chapter05> python > > > code1.py Enter your first name: Laura > > > Enter your last name: Jones > > > Enter your date of birth, mm-dd-yyyy: 12-24-1980 > > > You can chose one of the following login names: > > > 1. LauraJ > > > 2. LauraJ2412 > > > 3. JLaura80 > > > Traceback (most recent call last): > > > File "code1.py", line 67, in ? > > > fourth=fname[0]+lname+ age_func() > > > TypeError: cannot concatenate 'str' and 'NoneType' > > > objects > > > > > > What is going on here? > > > > Well the first line after "Traceback" give you the line > > of code and the filename. Which happens to be code1.py > > line 67. > > > > TypeError is the type of error - specifically you tried > > to do something with incompatible types. In this case, > > adding together a string and NoneType. > > > > I'll do a little digging, but my guess is you have a > > problem with your age_func() not returning any value. > > > > HTH, > > Wayne > > Why doe sit work with a dob in 1943 and not with one in 1980 > then, that's what really bugs me > -- > Bob Rea > mailto:gapet...@stsams.org > http://www.petard.us > http://www.petard.us/blog > http://www.petard.us/gallery > > Where is Bill Stringfellow > now that we really need him? > > > ------------------------------ > > Message: 6 > Date: Tue, 30 Jun 2009 12:45:00 -0700 > From: Marc Tompkins <marc.tompk...@gmail.com> > To: Bob Rea <b...@telaugos.com> > Cc: tutor@python.org > Subject: Re: [Tutor] Needing Help > Message-ID: > <40af687b0906301245n3ffcc950k458e4bf629530...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > On Tue, Jun 30, 2009 at 12:27 PM, Bob Rea <b...@telaugos.com> wrote: > > > Why doe sit work with a dob in 1943 and not with one in 1980 > > then, that's what really bugs me > > > > Nothing to do with the year. Your birth month is BEFORE June; her birth > month is after. > -- > www.fsrtechnologies.com > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20090630/0afb4e3c/attachment.htm > > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 64, Issue 135 > ************************************** > -- You will be a winner today. Pick a fight with a four-year-old. You should emulate your heros, but don't carry it too far. Especially if they are dead.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor