[Tutor] replacement for constants from other languages in Python?

2005-01-06 Thread Scott W
Hey all, I've done the usual googling, checked the Learning Python book and did some list searches, to no avail as of yet. I'm _very_ used to using C style constants (preprocessor #define directives) or C++ const keyword style, for a variety of reasons. I've yet to see anything covering 'how to

Re: [Tutor] replacement for constants from other languages in Python?

2005-01-06 Thread Scott W
Kent Johnson wrote: Scott W wrote: The 'need' to define a global constant in an imported module, for example- (I know about sys.version_info, but it doesn't exist in 1.5.2...don't ask ;-) I also know this could be handled via a class, but what is the equivalent of the foll

[Tutor] Changing (Unix) environment for python shell/popen() commands

2005-01-23 Thread Scott W
Hey all. I'm unfortunately stuck using python 1.5.2, primarily on Linux currently, and have done the usual searching (on list, active state, google), without luck. I've got to shell out from my python code to execute a command, but _must_ set the environment at the same time (or prior to execut

[Tutor] help with regexps/filename parsing

2005-01-31 Thread Scott W
Hey all. I've got an issue that's been driving me a bit nuts. I'm sure it _can_ be done with a regexp, although I'm missing a piece needed to tie it together to work for all cases. I need to parse out a list of RPMs in this case, but it seems the RPM naming convention has changed, as there are

Re: [Tutor] help with regexps/filename parsing

2005-01-31 Thread Scott W
Slight correction which I realized after sending, see below for version/release seperation, which I should have seen but blame lack of sleep ;-) Scott W wrote: Hey all. I've got an issue that's been driving me a bit nuts. I'm sure it _can_ be done with a regexp, although I&#x

[Tutor] Function help

2014-02-23 Thread Scott W Dunning
I am VERY new to python (programming too). I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that? I am trying to code an American Flag usin

Re: [Tutor] Function help

2014-02-23 Thread Scott W Dunning
On Feb 23, 2014, at 1:12 AM, Scott W Dunning wrote: > I am VERY new to python (programming too). I had a question regarding > functions. Is there a way to call a function multiple times without > recalling it over and over. Meaning is there a way I can call a function and > th

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 5:31 AM, Dave Angel wrote: > > Welcome to the tutor forum also, Scott. You'll find it works very > similarly to python-list, and has many of the same people on it. > I'm not sure how you tried to attach source, but please be aware > that this is a text list - anything othe

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote > a programmer would think "for loop” immediately That’s what I thought. It just seemed like way to much to keep repeating everything over and over. I knew there had to be a better way we just haven’t learned loops in school yet.

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote: > If you want to make rows with more or less stars, or stars in other colors > you could add parameters: > > def star_row(numstars, starcolor): >for i in range(numstars): >fillstar(starcolor) >space(25) > > Y

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote: > which still shows a repetetive pattern and thus you can simplify it with > another loop. You should be able to find a way to write that loop with two > star_row() calls on a single iteration, but can you do it with a single call

[Tutor] Help with "Guess the number" script

2014-02-28 Thread Scott W Dunning
Hello, i am working on a project for learning python and I’m stuck. The directions are confusing me. Please keep in mind I’m very ne to this. The directions are long so I’ll just add the paragraphs I’m confused about and my code if someone could help me out I’d greatly appreciate it! Also, w

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 12:47 AM, Ben Finney wrote: > You've bound the name ‘current_guess’ to the user's input, but then do > nothing with it for the rest of the function; it will be discarded > without being used. Hmm, I’m not quite sure I understand. I got somewhat confused because the direction

Re: [Tutor] Help with "Guess the Number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 8:57 AM, Mark Lawrence wrote: > On 01/03/2014 06:05, Scott Dunning wrote: > > In addition to the answers you've already had, I suggest that you learn to > run code at the interactive prompt, it's a great way of seeing precisely what > snippets of code actually do. Also use

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 6:53 AM, spir wrote: > > I find directions very confusing. Also, they completely control you while > explaining about nothing, like a user manual saying "press this, turn that". > This is inappropriate for programming (and anything else): you need to > understand! You need

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread Scott W Dunning
On Mar 2, 2014, at 12:43 AM, Ben Finney wrote: > > No, that's the opposite direction :-) Inside the ‘get_guess’ function > you should use as many names as you need for the different purposes. > > So, you have one name ‘guess_number’ bound to the function's parameter. > Don't bind anything else

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread Scott W Dunning
This is what Im having trouble with now. Here are the directions I’m stuck on and what I have so far, I’ll bold the part that’s dealing with the instructions if anyone could help me figure out where I’m going wrong. Thanks! from random import randrange randrange(1, 101) from random import s

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 1:51 AM, Ben Finney wrote: > "Bold” assumes that markup of text will survive; that's not reliable, > since this is a text-only medium and only the plain text will reliably > survive to all readers. Sorry, I didn’t realize. I’m still new to this. > > You're creating a prompt s

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 3:27 AM, spir wrote: > > There are 2 user guesses here, and only 1 variable, thus 1 name. The name > should say what (idea) the variable represents in the program; this should be > said by the name's *meaning*. It is one of the greatest difficulties in > programming. How wo

Re: [Tutor] Help with "Guess the number" script

2014-03-04 Thread Scott W Dunning
On Mar 3, 2014, at 3:29 AM, spir wrote: I have another question in regard to this guess the number script I’m working on. I’m banging my head over why this isn’t working…. def print_hints(secret, guess): if guess < 1 or guess > 101: print print "Out of range!" prin

[Tutor] Help with Guess the number script

2014-03-07 Thread Scott W Dunning
I am trying to write a script for class for a game called guess the number. I’m almost done but, I’m having a hard time getting the hints to print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like everything….I’m posting my code for the hints below, any help is greatly appreciated! d

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread Scott W Dunning
On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! This is what I got, not sure if it’s correct but it’s working! def print_hints(secret, guess): if guess < 1 or guess > 100: print print "Out of range!" print if gues

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 7:29 AM, eryksun wrote: > i.e. > >guess < 1 or guess > 100 > > becomes > >not not (guess < 1 or guess > 100) Why a not not? Wouldn’t that just be saying do this because the second not is undoing the first? > > distribute over the disjunction > >not (not (gue

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 7:35 AM, Mark Lawrence wrote: > > I have no interest in the efficiency, only what is easiest for me to read, > which in this case is the chained comparison. As a rule of thumb I'd also > prefer it to be logically correct :) > What exactly is ment by a chained comparison?

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 10, 2014, at 4:15 AM, eryksun wrote: > > Different strokes for different folks. I like to tinker with and > disassemble things as I'm learning about them. I would have been > ecstatic about open source as a kid. I learn simultaneously from the > top down and bottom up -- outside to inside

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
>> On Mar 8, 2014, at 3:57 AM, spir wrote: >>> >>> Well done. >>> And now that you have the right set of tests you can >>> half the number of lines by combining your if >>> conditions again, like you had in the original >>> post. ie. Bring your hot/cold/warm tests together. So below is what I fi

Re: [Tutor] Python implementations (was: Help with Guess the number script)

2014-03-10 Thread Scott W Dunning
On Mar 10, 2014, at 8:52 PM, Ben Finney wrote: > > What does the Python interactive prompt display when you first launch an > interactive Python shell? Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or

Re: [Tutor] Python implementations (was: Help with Guess the number script)

2014-03-10 Thread Scott W Dunning
On Mar 10, 2014, at 8:52 PM, Ben Finney wrote: > > What does the Python interactive prompt display when you first launch an > interactive Python shell? Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or

Re: [Tutor] Help with Guess the number script

2014-03-10 Thread Scott W Dunning
On Mar 8, 2014, at 11:50 AM, Scott dunning wrote: >>> >>> And now that you have the right set of tests you can >>> half the number of lines by combining your if >>> conditions again, like you had in the original >>> post. ie. Bring your hot/cold/warm tests together. I’m having a hard time doing

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: > Scott W Dunning Wrote in message: >> > > Would you please stop posting in html? I don’t know what you mean? I just use the text for my email provider. It’s not html? I types up the code I ha

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: Where are you guys using the forum? Through google? I was using that at first but someone complained about something that google does and told me to get it through my email. That’s what I’m doing now and I get bombarded with about 500 emails

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 11, 2014, at 1:49 AM, Alan Gauld wrote: > > Not from the tutor list though. It only has a few > mails normally - less than 50 most days. > Actually now that you say that most of the emails are coming through the reg python-lists, not the tutor section. I guess I should just unsubscribe

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread Scott W Dunning
On Mar 11, 2014, at 7:50 PM, William Ray Wing wrote: > > Simple. In Mail Preferences -> Composing -> Message Format -> Plain Text > (Your setting is probably currently Rich Text.) > Got it, hopefully that helps. ___ Tutor maillist - Tutor@python

[Tutor] Project suggestions

2014-03-12 Thread Scott W Dunning
Hey Everyone, I just got through doing a Guess-the-number script and was looking for something else to practice on. Do any of you have any suggestions on some things I could work on? Keep in mind I am not only extremely new to python I am new to programming. Thanks for any suggestions!!! Sc

Re: [Tutor] while loop

2014-03-28 Thread Scott W Dunning
On Mar 28, 2014, at 9:54 PM, Scott W Dunning wrote: > Hello, I’m working on some practice exercises from my homework and I’m having > some issues figuring out what is wanted. > > We’re working with the while loop and this is what the question states; > > Write a fun

[Tutor] while loop

2014-03-28 Thread Scott W Dunning
Hello, I’m working on some practice exercises from my homework and I’m having some issues figuring out what is wanted. We’re working with the while loop and this is what the question states; Write a function print_n that prints a string n times using iteration. """Print the string `s`

[Tutor] exercise (while loop)

2014-03-31 Thread Scott W Dunning
I’m working on a few exercises and I’m a little stuck on this one. This is what the book has but it just gives me an endless loop. def square_root(a, eps=1e-6): while True: print x y = (x + a/x) / 2 if abs(y-x) < epsilon:

Re: [Tutor] exercise (while loop)

2014-03-31 Thread Scott W Dunning
On Mar 31, 2014, at 7:10 PM, Danny Yoo wrote: Thanks for the info Danny! I’ll try that and I should be able to figure it out with your help! The book I was referring to is greentreepress. ___ Tutor maillist - Tutor@python.org To unsubscribe or c

[Tutor] Final review

2014-05-01 Thread Scott W Dunning
Hello, I am new to python and have a final review coming up and was hoping you could help me answer a few questions I came across while studying. So, I get a little confused about lists sometimes. This one is a little hard to make heads or tails of. I get confused about how to tell how many l

Re: [Tutor] Final review

2014-05-05 Thread Scott W Dunning
On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: Awesome, thanks everyone! I understand lists a lot better now. I have another question. I don’t understand why below would give an error? >>> greeting = 'Hello World’ >>> greeting [len(greeting)] _

Re: [Tutor] Final review

2014-05-07 Thread Scott W Dunning
On May 5, 2014, at 10:13 PM, meenu ravi wrote: > Likewise, the index of d, which is the last word in the word "Hello world" is > 10. > > So, the maximum index you can access in the word "Hello world" is 10. But > when you try to give the command, > > >>> greeting [len(greeting)] > > It is t

Re: [Tutor] Installing twisted

2014-11-27 Thread Scott W Dunning
Hey guys I was hoping someone could tell me how to opted out of this list? I have it going to two email addresses for some reason and I unsubscribed but nothing happened. Any help is greatly appreciated! Thanks, Scott ___ Tutor maillist - Tut