Re: [Tutor] Python Editor to Start Out WithTutor Digest, Vol 92, Issue 123

2011-10-31 Thread Alan Gauld
On 31/10/11 04:40, cyclicf...@yahoo.com wrote: With reference to a beginning editor, I agree with most of this but... ... scripting in vim has many similarities to various types in python. The python forloop is definitely very similar Thats probably because you have a vim that has been

Re: [Tutor] importing modules and packages

2011-10-31 Thread Steven D'Aprano
neubyr wrote: Is it possible to tell whether import statement is importing a module or package? I am going through some example code with some import statements - like 'import os, sys, time', 'import packed'. I know os, sys and time are (built-in) modules and 'packed' is a package here . But

Re: [Tutor] Tutor Digest, Vol 92, Issue 123

2011-10-31 Thread Rinu Boney
I Use Windows.I Already Know C/C++ which makes python syntax seem very easy. Maybe Setting Up Emacs With Python Will Make Me Productive. I Have Eclipse With PyDev. Why Is There Not A Pythonic Emacs? On Mon, Oct 31, 2011 at 8:23 AM, tutor-requ...@python.org wrote: Send Tutor mailing list

[Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
Hello everyone, I am having a little trouble with a block of code that isn't behaving the way I would expect. Maybe you can give me a hand and point where it is going wrong. The function that is not working correctly belongs to a Paper Rock Scissor game I am making. This particular

Re: [Tutor] Tutor Digest, Vol 92, Issue 127

2011-10-31 Thread Asokan Pichai
From: Joel Montes de Oca joelmonte...@gmail.com To: Tutor Python tutor@python.org Subject: [Tutor] Paper Rock Scissors game - User's choice not returned properly Message-ID: 4eaec191.3060...@gmail.com Content-Type: text/plain; charset=iso-8859-1; Format=flowed Hello everyone, The

Re: [Tutor] Tutor Digest, Vol 92, Issue 127

2011-10-31 Thread Joel Montes de Oca
On Mon 31 Oct 2011 11:59:47 AM EDT, Asokan Pichai wrote: From: Joel Montes de Oca joelmonte...@gmail.com mailto:joelmonte...@gmail.com To: Tutor Python tutor@python.org mailto:tutor@python.org Subject: [Tutor] Paper Rock Scissors game - User's choice not returned

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Hugo Arts
On Mon, Oct 31, 2011 at 4:41 PM, Joel Montes de Oca joelmonte...@gmail.com wrote: Hello everyone, I am having a little trouble with a block of code that isn't behaving the way I would expect. Maybe you can give me a hand and point where it is going wrong. The function that is not working

Re: [Tutor] importing modules and packages

2011-10-31 Thread neubyr
On Mon, Oct 31, 2011 at 4:38 AM, Steven D'Aprano st...@pearwood.info wrote: neubyr wrote: Is it possible to tell whether import statement is importing a module or package?  I am going through some example code with some import statements - like 'import os, sys, time', 'import packed'. I know

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
On Mon 31 Oct 2011 12:14:40 PM EDT, Hugo Arts wrote: On Mon, Oct 31, 2011 at 4:41 PM, Joel Montes de Oca joelmonte...@gmail.com wrote: Hello everyone, I am having a little trouble with a block of code that isn't behaving the way I would expect. Maybe you can give me a hand and point where it

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread Asokan Pichai
Hugo's explanation is nice and clear. You may also want to look at this way Consider the most simplified form of the issue def alpha(): if X: beta() else: return q Here in the* if branch* nothing is returned while in the *else branch *something is being

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel M.
On Mon, Oct 31, 2011 at 1:09 PM, Joel Montes de Oca joelmonte...@gmail.comwrote: On Mon 31 Oct 2011 12:14:40 PM EDT, Hugo Arts wrote: On Mon, Oct 31, 2011 at 4:41 PM, Joel Montes de Oca joelmonte...@gmail.com joelmonte...@gmail.com wrote: Hello everyone, I am having a little trouble

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
On 10/31/2011 11:41 AM, Joel Montes de Oca wrote: Hello everyone, I am having a little trouble with a block of code that isn't behaving the way I would expect. Maybe you can give me a hand and point where it is going wrong. The function that is not working correctly belongs to a Paper Rock

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Marc Tompkins
On Mon, Oct 31, 2011 at 10:57 AM, Joel Montes de Oca joelmonte...@gmail.com wrote:  I came up with this to solve the problem. def UserChoice ():    # The function that returns the choice from the user     while 1:         print 'Please select (P) for paper, (R) for Rock, or (S) for

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Prasad, Ramit
Just a minor note, this break is redundant. Breaks are used to exit (for/while) loops but keep control in the function. A return exits the function immediately. if choice.lower() in ('p', 'r','s'):# Converts the user's choice to lowercase and confirms the choice is valid

Re: [Tutor] Tutor Digest, Vol 92, Issue 123

2011-10-31 Thread Alan Gauld
On 31/10/11 12:56, Rinu Boney wrote: I Use Windows.I Already Know C/C++ which makes python syntax seem very easy. Maybe Setting Up Emacs With Python Will Make Me Productive. If you learn emacs then it will. But learning emacs is almost as big a task as learning Python, it is a complete user

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
On 10/31/2011 02:13 PM, Prasad, Ramit wrote: Just a minor note, this break is redundant. Breaks are used to exit (for/while) loops but keep control in the function. A return exits the function immediately. if choice.lower() in ('p', 'r','s'):# Converts the user's choice to

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Alan Gauld
On 31/10/11 17:09, Joel Montes de Oca wrote: FUN MAIN | | |__ FUN A | | |_ FUN B This is how I understand it. So if I want this to work, I need FUN B to give something back to FUN A so that FUN A will have something to give back to FUN MAIN but that

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
On 10/31/2011 02:14 PM, Marc Tompkins wrote: On Mon, Oct 31, 2011 at 10:57 AM, Joel Montes de Oca joelmonte...@gmail.com wrote: I came up with this to solve the problem. def UserChoice ():# The function that returns the choice from the user while 1: print 'Please select

[Tutor] Use of subject line [Was: Re: Tutor Digest, Vol 92, Issue 127]

2011-10-31 Thread Alan Gauld
On 31/10/11 15:59, Asokan Pichai wrote: From: Joel Montes de Oca joelmonte...@gmail.com mailto:joelmonte...@gmail.com To: Tutor Python tutor@python.org mailto:tutor@python.org Subject: [Tutor] Paper Rock Scissors game - User's choice not returned properly If

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Wayne Werner
On Mon, Oct 31, 2011 at 1:14 PM, Marc Tompkins marc.tompk...@gmail.comwrote: You could simplify it even further by actually using the while: def UserChoice ():# The function that returns the choice from the user choice = '' attempt = 0 while choice.lower() not in ('p',

Re: [Tutor] Tutor Digest, Vol 92, Issue 123

2011-10-31 Thread Tim Johnson
* Rinu Boney rinu.mat...@gmail.com [111031 07:03]: I Use Windows.I Already Know C/C++ which makes python syntax seem very easy. Maybe Setting Up Emacs With Python Will Make Me Productive. I Have Eclipse With PyDev. Why Is There Not A Pythonic Emacs? Rinu, by this time I believe that Alan has

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Peter Otten
Alan Gauld wrote: if choice.lower() not in ('prs'): # NB use a single string That's not a good idea. If a user accidentally enters PR (for example) your version will mistake that for a valid choice. ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Peter Otten
Joel Montes de Oca wrote: def UserChoice (): # The function that returns the choice from the user while 1: print 'Please select (P) for paper, (R) for Rock, or (S) for Scissors.' choice = raw_input('What is your selection?:') if

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread Steven D'Aprano
Asokan Pichai wrote: Hugo's explanation is nice and clear. [...] Who are you replying to, and what was the question? Thank you for NOT quoting the entire digest, hundreds and hundreds of lines! You would be amazed at how many people do that. But in future, could you please quote *just

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Alan Gauld
On 31/10/11 20:22, Peter Otten wrote: Alan Gauld wrote: if choice.lower() not in ('prs'): # NB use a single string That's not a good idea. If a user accidentally enters PR (for example) your version will mistake that for a valid choice. Good point, although you could test the first

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread Alan Gauld
On 31/10/11 20:55, Steven D'Aprano wrote: You may prefer to change to individual emails instead of digest mode. In my opinion, digest mode is only useful when you want to read other people's comments without commenting yourself. It depends, I've used digests from other lists that delivered

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread Dave Angel
On 10/31/2011 06:09 PM, Alan Gauld wrote: On 31/10/11 20:55, Steven D'Aprano wrote: You may prefer to change to individual emails instead of digest mode. In my opinion, digest mode is only useful when you want to read other people's comments without commenting yourself. It depends, I've used

Re: [Tutor] Tutor Digest, Vol 92, Issue 128

2011-10-31 Thread bob gailer
On 10/31/2011 1:26 PM, Asokan Pichai wrote: Hugo's explanation is nice and clear. You may also want to look at this way Consider the most simplified form of the issue def alpha(): if X: beta() else: return q Here in the*if branch* nothing is returned None

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Steven D'Aprano
Alan Gauld wrote: On 31/10/11 20:22, Peter Otten wrote: Alan Gauld wrote: if choice.lower() not in ('prs'): # NB use a single string That's not a good idea. If a user accidentally enters PR (for example) your version will mistake that for a valid choice. Good point, although you could

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Steven D'Aprano
Joel Montes de Oca wrote: When the user enters an invalid letter, FUNCTION B calls FUNCTION A. FUNCTION A returns choice to FUNCTION B. FUNCTION B does nothing with the return, FUNCTION MAIN gets nothing to returned to it, thus choice is NONE. FUN MAIN | | |__ FUN A |

[Tutor] Help

2011-10-31 Thread Chris Kavanagh
This code is from the book 'Invent your own computer games with Python' 2nd edition. Great book so far. . . My question comes on the 2nd game (dragon game). Just a simple little program that lets you choose to enter 'cave one' or 'cave two' by using the random module, radnom.randint. If you

Re: [Tutor] Simple Question On A Method (in subclass)

2011-10-31 Thread Steven D'Aprano
Marc Tompkins wrote: It can be a little hard to wrap your head around how Python handles variables/objects; in other languages you create a variable and assign a value to it, while in Python you create an object and assign a name to it - the name can change while the object remains unchanged.

Re: [Tutor] Help

2011-10-31 Thread Steven D'Aprano
Chris Kavanagh wrote: However, I'm confused on Line 30 {if chosenCave== str(friendlyCave)}. Here's the description of this line the author gives: Here we check if the integer of the cave we chose ('1' or '2') is equal to the cave randomly selected to have the friendly dragon My question

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-10-31 Thread Joel Montes de Oca
On 10/31/2011 07:10 PM, Steven D'Aprano wrote: Alan Gauld wrote: On 31/10/11 20:22, Peter Otten wrote: Alan Gauld wrote: if choice.lower() not in ('prs'): # NB use a single string That's not a good idea. If a user accidentally enters PR (for example) your version will mistake that for a

Re: [Tutor] Help

2011-10-31 Thread Chris Kavanagh
Yes Steven, that solved my question(s). It also cleared up what was to be my next question! Thanks so much. You might not realize how grateful I am to be able to have you others on the list answer my questions. Just trust me when I say, I am grateful. And I apologize for the code being

Re: [Tutor] Help

2011-10-31 Thread Chris Kavanagh
I'm going to thank Steven once again, and answer my own question in the 2nd paragraph directly below (Steven hasn't had a chance to respond yet). I just learned that the Function definitions are not read by the interpreter UNTIL they are called. I was reading them and assuming they were

[Tutor] Pickle Class Instances

2011-10-31 Thread Rinu Boney
This Is My Program : class book: def __init__(self,bno=100,bname='Book'): self.book_number=bno self.book_name=bname def enter_book(self): self.book_number=input(Enter Book No : ) self.book_name=input(Enter Book Name : ) def display_book(self):

[Tutor] Pickling Class Instances

2011-10-31 Thread Rinu Boney
I have a class 'book' and function for input and display of the class members then there are 2 functions for pickling and unpickling class instances from and to a file. after unpickling , then displaying it shows only the last class instance stored in the file! what can be the possible problems?