Re: [Tutor] defining functions and classes

2011-01-15 Thread Brett Murch
Yes you are right it is a Name error because skills was not defined. Sorry will make things more clear in the future. I have it sorted now. Will just start from the beginning and try not to go to fast. On Sat, 2011-01-15 at 21:34 +1100, Steven D'Aprano wrote: > Brett Murch wrote: > > > I keep ge

Re: [Tutor] defining functions and classes

2011-01-15 Thread Brett Murch
On Sat, 2011-01-15 at 08:23 -0500, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Brett Murch wrote: > > Hi everyone, > > > > I'm just starting to learn Python and am starting by creating a text > > game but am having trouble with classes and funtions. I want to create a > > class or function where

Re: [Tutor] defining functions and classes

2011-01-15 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Brett Murch wrote: Hi everyone, I'm just starting to learn Python and am starting by creating a text game but am having trouble with classes and funtions. I want to create a class or function where someone creates a charater and has a choice of their name or os. This i

Re: [Tutor] defining functions and classes

2011-01-15 Thread Alan Gauld
"Brett Murch" wrote game but am having trouble with classes and funtions. I want to create a class or function where someone creates a charater and has a choice of their name or os. This is what I have so far; class Administrator(): def Skills(name,os): OK, You have a ways to go to und

Re: [Tutor] defining functions and classes

2011-01-15 Thread Steven D'Aprano
Brett Murch wrote: I keep getting a syntax error on calling it. any ideas on what I'm doing wrong? Should we *guess*, or would you like to share with us the actual error you are getting? My guess is that you're not getting a syntax error at all, you're getting a NameError that Skills is no

Re: [Tutor] defining functions and classes

2011-01-15 Thread Kann Vearasilp
Do you also have to define the class attributes? class Administrator(): name = "" os = "" def Skills(name,os): name = raw_input('What is your name') os = raw_input('What is your os') self.name = name self.os = os Skills(name,os) On Sat, Jan 15, 2011 at 11:10

Re: [Tutor] Defining functions

2005-03-27 Thread Kent Johnson
- print is just being changed to a function (instead of a statement), it's not going away entirely. But for complete future compatibility I guess you would avoid it. - I don't think you will ever get the prompt as part of the input unless the user actually types it - You can strip the trailing new

Re: [Tutor] Defining functions

2005-03-26 Thread Jacob S.
Try this. import sys def my_raw_input(prompt): sys.stdout.write(prompt)## Since they're thinking of bonking off print as well. a = sys.stdin.readline() if a.startswith(prompt): return a[:len(prompt)] return a It leaves the '\n' on the end... so it sucks. I know there is

Re: [Tutor] Defining functions

2005-03-25 Thread Gabriel Farrell
So, as a newbie, I see this thread and I check out the PEP and I see that for future compatibility we should use sys.stdin.readline(). So I import sys to see how it works. Of course, sys.stdin.readline('type anything: ') doesn't work in quite the same way as raw_input('type anything: ') does. Th

Re: [Tutor] Defining functions

2005-03-25 Thread Jacob S.
Yeah. And they're thinking of removing raw_input() too. I think it's good to have a __builtin__ user input function. Why should we have to import sys everytime we want user input? Almost every program that newbies write uses it, and advanced programmers also if they're using console programs.

Re: [Tutor] Defining functions

2005-03-25 Thread Kent Johnson
Michael Dunn wrote: Something I've always wondered: if input() is so dangerous, why is it there? What valid uses does it have in the wild? It's a mistake planned to be removed in Python 3.0, the "hypothetical future release of Python that can break backwards compatibility with the existing body of

Re: [Tutor] Defining functions

2005-03-25 Thread Michael Dunn
Something I've always wondered: if input() is so dangerous, why is it there? What valid uses does it have in the wild? I ask this because this confusion comes up a lot: people expect input() to return a string and it throws them when it doesn't. We all just learn to use raw_input(), and to forget

Re: [Tutor] Defining functions

2005-03-25 Thread Alan Gauld
> If I try to change the 1, 2, 3, 4 or 5 by a letter i.e. a, b, c, d, e the > programme stop functionning. I get an error message saying that > > Traceback (most recent call last): > File "C:/Python24/Example/area_cir_squ_regt.py", line 39, in -toplevel- > print_options() > File "C:/Python2

Re: [Tutor] Defining functions

2005-03-24 Thread Kent Johnson
John Carmona wrote: Hi there, I have written (well almost as I copied some lines from an existing example) this little programme - part of an exercise. def print_options(): print "--" print "Options:" print "1. print options" print "2. calcu

Re: [Tutor] Defining functions

2005-03-24 Thread Michael Dunn
Hi John, when you want user input, you almost always need raw_input(), not input(). Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

RE: [Tutor] Defining functions

2005-03-24 Thread Ryan Davis
Did you put them in quotes? # If choice == 'c': ... # Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Carmona Sent: Thursday, March 24, 2005 5:52 PM To: tutor@python.org Subject: [Tutor] Defining functions Hi there, I have written