Re: [Tutor] Beginner question on classes

2013-10-23 Thread Dave Angel
On 23/10/2013 03:25, Corinne Landers wrote: > --> > Hi guys, I > need a bit of help. I'm writing a class, and in the main > function I'm trying to say if this method gets called, do > this. I'm trying things > like:program = AnimalClass(x,y,z)for i > in range(x):   for j in range(y):  >    

Re: [Tutor] Beginner question on classes

2013-10-23 Thread Oscar Benjamin
On 23 October 2013 08:25, Corinne Landers wrote: > Hi guys, Hi Corrine, > I need a bit of help. > I'm writing a class, and in the main function I'm trying to say if this > method gets called, do this. > I'm trying things like: > > program = AnimalClass(x,y,z) > for i in range(x): >for j in r

Re: [Tutor] Beginner question on classes

2013-10-23 Thread Alan Gauld
On 23/10/13 08:25, Corinne Landers wrote: Hi guys, I need a bit of help. I'm writing a class, and in the main function I'm trying to say if this method gets called, do this. What you are actually doing is "if the method returns a truth-like value do this." Not quite the same thing, but much ea

Re: [Tutor] Beginner Question

2013-10-23 Thread Oscar Benjamin
On 23 October 2013 08:58, Albert-Jan Roskam wrote: > So the built-in 'len()' is *really* a function, but calls to len() > implemented by __len__ are method calls *disguised* as function calls? I > sometimes find it easier to write calls to special methods the "normal" way, > e.g. instead of "

[Tutor] Beginner question on classes

2013-10-23 Thread Corinne Landers
Hi guys, I need a bit of help. I'm writing a class, and in the main function I'm trying to say if this method gets called, do this. I'm trying things like: program = AnimalClass(x,y,z)for i in range(x): for j in range(y): for k in range(z): animal = program.animal() if animal:

Re: [Tutor] Beginner Question

2013-10-23 Thread Albert-Jan Roskam
On Wed, 10/23/13, Steven D'Aprano wrote: Subject: Re: [Tutor] Beginner Question To: tutor@python.org Date: Wednesday, October 23, 2013, 5:27 AM On Tue, Oct 22, 2013 at 04:25:59PM +0200, Sven Hennig wrote: >  Hello, I would like to

Re: [Tutor] Beginner Question

2013-10-22 Thread Steven D'Aprano
On Tue, Oct 22, 2013 at 04:25:59PM +0200, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to use > Python. I have some programming experience and doing well in Python. What > really causes me problems is OOP. > I'm just dont get it... I'm missing a really

Re: [Tutor] Beginner Question

2013-10-22 Thread Alan Gauld
On 22/10/13 19:18, Sven Hennig wrote: Thank you! You guys helped me out alot. @Alan your website is great! Really clearly written. Especially the "Things to remember" part. Glad you like it. Someday (soon!) I'll get round to finishing the v3 version... So much to do, so little time! If you h

Re: [Tutor] Beginner Question

2013-10-22 Thread Sven Hennig
Thank you! You guys helped me out alot. @Alan your website is great! Really clearly written. Especially the "Things to remember" part. If you have exercises for me or have a Website with exercises, bring it on. I think this is the best way to learn. 2013/10/22 Dave Angel > On 22/10/2013 10:2

Re: [Tutor] Beginner Question

2013-10-22 Thread Dave Angel
On 22/10/2013 10:25, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to use > Python. I have some programming experience and doing well in Python. What > really causes me problems is OOP. > I'm just dont get it... I'm missing a really Practical example. I

Re: [Tutor] Beginner Question

2013-10-22 Thread Andy McKenzie
On Tue, Oct 22, 2013 at 10:25 AM, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to > use Python. I have some programming experience and doing well in Python. > What really causes me problems is OOP. > I'm just dont get it... I'm missing a really Practica

Re: [Tutor] Beginner Question

2013-10-22 Thread Alan Gauld
On 22/10/13 15:25, Sven Hennig wrote: Hello, I would like to learn a programming language and have decided to use Python. I have some programming experience and doing well in Python. What really causes me problems is OOP. Don't worry this is common. The problem with OOP is that it only really b

[Tutor] Beginner Question

2013-10-22 Thread Sven Hennig
Hello, I would like to learn a programming language and have decided to use Python. I have some programming experience and doing well in Python. What really causes me problems is OOP. I'm just dont get it... I'm missing a really Practical example. In every book I've read are the examples of such C

Re: [Tutor] Beginner question

2013-08-12 Thread Krishnan Shankar
>But in the code there is a flaw. input() will evaluate your user input. i.e. If you give an integer >expression it will tell the answer. And when you provide a number it will take it as int type. See >below. Hi, Ignore my above statements if using Python 3. Sorry my bad. Had a doubt and went to

Re: [Tutor] Beginner question

2013-08-12 Thread Krishnan Shankar
>def checkCave(chosenCave): > print('You approach the cave...') >time.sleep(2) > print('It is dark and spooky...') > time.sleep(2) >print('A large dragon jumps out in front of you! He opens his jaws and...') >print() > time.sleep(2) >friendlyCave = random.randint(1, 2) >

Re: [Tutor] Beginner question

2013-08-12 Thread Jim Mooney
On 12 August 2013 02:14, Karim Liateni wrote: > 5ÿt5ÿ6hhhyyyfrrtr > > eschneide...@comcast.net a écrit : > > >I've been learning python from the website 'inventwithpython.com', and > I'm on a chapter that covers the following code: > Just a quick note - not on the algorithm itself. If you run th

Re: [Tutor] Beginner question

2013-08-12 Thread Ciaran Mooney
On 10 Aug 2013, at 04:30, eschneide...@comcast.net wrote: > I've been learning python from the website 'inventwithpython.com', and I'm on > a chapter that covers the following code: > > import random > import time > def displayIntro(): > print('You are in a land full of dragons. In front of yo

Re: [Tutor] Beginner question

2013-08-11 Thread Alan Gauld
On 10/08/13 04:30, eschneide...@comcast.net wrote: I've been learning python from the website 'inventwithpython.com', and I'm on a chapter that covers the following code: import random import time def displayIntro(): print('You are in a land full of dragons. In front of you,') print('you

[Tutor] Beginner question

2013-08-11 Thread eschneider92
I've been learning python from the website 'inventwithpython.com', and I'm on a chapter that covers the following code: import random import time def displayIntro(): print('You are in a land full of dragons. In front of you,') print('you see two caves. In one cave, the dragon is friendly')

Re: [Tutor] beginner question

2011-11-01 Thread Steven D'Aprano
Mayo Adams wrote: When writing a simple for loop like so: for x in f where f is the name of a file object, how does Python "know" to interpret the variable x as a line of text, rather than,say, an individual character in the file? Does it automatically treat text files as sequences of line

Re: [Tutor] beginner question

2011-11-01 Thread Peter Otten
Steve Willoughby wrote: > On 01-Nov-11 08:34, Mayo Adams wrote: >> When writing a simple for loop like so: >> >> for x in f >> >> where f is the name of a file object, how does Python "know" to interpret >> the variable x as a line of text, rather than,say, an individual >> character in the

Re: [Tutor] beginner question

2011-11-01 Thread Steve Willoughby
On 01-Nov-11 08:34, Mayo Adams wrote: When writing a simple for loop like so: for x in f where f is the name of a file object, how does Python "know" to interpret the variable x as a line of text, rather than,say, an individual character in the file? Does it automatically treat text files

[Tutor] beginner question

2011-11-01 Thread Mayo Adams
When writing a simple for loop like so: for x in f where f is the name of a file object, how does Python "know" to interpret the variable x as a line of text, rather than,say, an individual character in the file? Does it automatically treat text files as sequences of lines? -- Mayo Adams

Re: [Tutor] Beginner question(s)

2006-06-19 Thread David Rock
* Ismael Garrido <[EMAIL PROTECTED]> [2006-06-18 19:34]: > Alan Gauld wrote: > >> Also, does anyone know of a PDA that would run python? > >> > > > > There was a project called pippy, but I haven't heard anything of it > > recently so I don't know if its still around or if it runs on modern

Re: [Tutor] Beginner question(s)

2006-06-18 Thread John Fouhy
> Also, does anyone know of a PDA that would run python? Some of the new Nokias run python: http://www.forum.nokia.com/python -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Beginner Question

2006-06-18 Thread Daniel McQuay
n, 18 Jun 2006 05:58:38 -0500 >From: "Bill Tatum" <[EMAIL PROTECTED]>>Subject: [Tutor] Beginner question(s)>To: <tutor@python.org>>Message-ID: < [EMAIL PROTECTED]>>Content-Type: text/plain; charset="us-ascii">>Hi,>>>>I'm work

Re: [Tutor] Beginner question(s)

2006-06-18 Thread Ismael Garrido
Alan Gauld wrote: >> Also, does anyone know of a PDA that would run python? >> > > There was a project called pippy, but I haven't heard anything of it > recently so I don't know if its still around or if it runs on modern > PDAs - I think it was PalmOS anyhow... > > Pippy is quite dea

Re: [Tutor] Beginner question(s)

2006-06-18 Thread Alan Gauld
> message = raw_input("Enter your message:") > for i in range(len(message)-1,-1, -1): >print i, > > but I just get the numeric values of the string. Can anyone help? As an alternative approach consider converting to a list and using the reverse method... > Also, does anyone know of a PDA t

Re: [Tutor] Beginner Question

2006-06-18 Thread Josh F
age: 1 >Date: Sun, 18 Jun 2006 05:58:38 -0500 >From: "Bill Tatum" <[EMAIL PROTECTED]> >Subject: [Tutor] Beginner question(s) >To: >Message-ID: <[EMAIL PROTECTED]> >Content-Type: text/plain; charset="us-ascii" > >Hi, > > > >I&

Re: [Tutor] Beginner question(s)

2006-06-18 Thread Michael Sullivan
On Sun, 2006-06-18 at 05:58 -0500, Bill Tatum wrote: > Hi, > > > > I’m working through Python Programming for the Absolute Beginner. One > of the challenges at the end of chapter 4 is to get a message from the > user and then print it out backwards. I have… > > > > message = raw_input("Ent

[Tutor] Beginner question(s)

2006-06-18 Thread Bill Tatum
Hi,   I’m working through Python Programming for the Absolute Beginner.  One of the challenges at the end of chapter 4 is to get a message from the user and then print it out backwards. I have…   message = raw_input("Enter your message:") count = len(message) print count   which giv

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-08 Thread Danny Yoo
> > ..which is not what I'm aiming for. Maybe I'll have to follow Bob's > > advice and just store all of the variable assignments in a function, > > and then call the function every time I change one of the variables > > (based on user input). I could still leave the higher-order variables > > as f

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-08 Thread Danny Yoo
> I tried redefining the "higher-order" variables as functions, but it > didn't quite work. Here's a simplified example: > > > var1 = 2 > > def timestwo(x): > return x*2 > > var2 = timestwo(var1) > print var1, var2 > var1 = 3 > print var1, var2 Try: ## print 2, timestwo(2) print 3, times

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-08 Thread Kent Johnson
> From: Jesse <[EMAIL PROTECTED]> > > I tried redefining the "higher-order" variables as functions, but it didn't > quite work. Here's a simplified example: > > > var1 = 2 > > def timestwo(x): > return x*2 > > > var2 = timestwo(var1) > print var1, var2 > var1 = 3 > print var1, var2 > > T

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-08 Thread Alan Gauld
Others have provided workarounds I'll attempt to answer the rationale part... > Why is it that when one variable is assigned a value in terms of another > variable, assigning a new value to the first doesn't change the value of > the > second? Python variables are just names that refer to a valu

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-07 Thread Danny Yoo
-- Forwarded message -- Date: Fri, 7 Apr 2006 21:05:33 -0600 From: Jesse <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Beginner question (variables, namespaces...) I tried redefining the "higher-order" variables as functions, bu

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
> > buy_containers = roundup(need/container) > > > Yeah, rather than code these as explicit variables, I'd strongly recommend > rewriting each of these as functions. Concretely: > > def buy_containers(stock, weekly_quota, container): > return roundup(need(stock, weekly_quota) - extra(stock,

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Bob Gailer
Jesse wrote: > Why is it that when one variable is assigned a value in terms of > another variable, assigning a new value to the first doesn't change > the value of the second? This is giving me a huge headache, since I > have a bunch of variables defined in terms of one another, and I want > t

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
On Fri, 7 Apr 2006, Jesse wrote: > Why is it that when one variable is assigned a value in terms of another > variable, assigning a new value to the first doesn't change the value of > the second? Hi Jesse, If you have a "variable" that depends on the values of other parameters, that's just be

[Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Jesse
Why is it that when one variable is assigned a value in terms of another variable, assigning a new value to the first doesn't change the value of the second? This is giving me a huge headache, since I have a bunch of variables defined in terms of one another, and I want to be able to dynamically up