Re: Some basic newbie questions...

2007-01-02 Thread Kent Johnson
jonathan.beckett wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). Another explanation here:

Re: Some basic newbie questions...

2006-12-29 Thread Duncan Booth
jonathan.beckett [EMAIL PROTECTED] wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). When it comes down to it, its a design decision, so neither right nor wrong in

Re: Some basic newbie questions...

2006-12-29 Thread Daniel Klein
On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, Question 2... What is the correct way of looping through a list object in a class via a method of it? Without peeking at any of the other responses, here is what I came up with. I hope it helps... class

Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with some basic code, but I have ended up with a few questions that

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with

Re: Some basic newbie questions...

2006-12-28 Thread Chris Mellon
On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Chris Mellon wrote: On 28 Dec 2006 08:40:02 -0800, jonathan.beckett [EMAIL PROTECTED] wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Hi Grant, thanks for the code snippets - made total sense. On the evidence of the last couple of hours, Python is still feeling very alien, but I'm starting to get my head around it. I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: Given the code below, why does the count method return what it does? How *should* you call the count method? a = [] a.append(1) print a.count print a.count(). Which will cause an exception, BTW, since the count method

Re: Some basic newbie questions...

2006-12-28 Thread Grant Edwards
On 2006-12-28, jonathan.beckett [EMAIL PROTECTED] wrote: I'm just finding it a bit weird that some of the built in functions are static, rather than methods of objects (such as len() being used to find the length of a list). Well, they actually are methods of objects (at least they are now --

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
I normally work with PHP, C#, Javascript, and the odd bit of C++, Do any of them call functions w/o parens? That's a really good point :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Some basic newbie questions...

2006-12-28 Thread Scott David Daniels
jonathan.beckett wrote: Hi all, While working on support at work, I have been picking away at Python - because I think it could be a valuable scripting tool for building utilities from. I have been reading the python.org tutorials, and playing around with some basic code, but I have ended

Re: Some basic newbie questions...

2006-12-28 Thread jonathan.beckett
Too many misconceptions here (I changed to a more PEP-8 style naming): class Gun(object): def __init__(self): self.shells = 10 class Battleship(object): def __init__(self): self.guns = [Gun(), Gun()] def getShellsLeft(self):

Re: Some basic newbie questions...

2006-12-28 Thread Scott David Daniels
jonathan.beckett wrote: ... class Battleship(object): ... def getShellsLeft(self): numShells = 0 for aGun in self.guns: numShells += aGun.shells return numShells ... Excellent example - once upon a time I used to