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 learn a progr

[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 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 "

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 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 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] How to Terminate a Popen call?

2013-10-23 Thread SM
Hello eryksun, Thanks, very much, for the very quick and helpful reply. It fixed my problem. -Sm On Tue, Oct 22, 2013 at 10:33 PM, eryksun wrote: > On Tue, Oct 22, 2013 at 9:04 PM, SM wrote: > > def run(self): > > (process, err) = Popen(self.fwcmd, stdout=PIPE, > > std

[Tutor] The meaning of self

2013-10-23 Thread Glenn Lester
I have come across the term "self" in a number of Python scripts and as a beginner to the language I am wondering if it has any specific meaning. It is usually used in the same manner as in this example by Steven D'Aprano. class DefaultModelCar: model = "Unknown" BRAKE_COMMAND = "B"

[Tutor] export postgresql to unified, templated xml

2013-10-23 Thread Ismar Sehic
Hello all.i have a quite big task, but i have a feeling it could be easily solved using python. The thing is, i need to export the whole company DB(Postgresql) to an XML template provided by another company. the template looks like this(just a fragment) : ?xml version="1.0" encoding="utf-8"?>

Re: [Tutor] The meaning of self

2013-10-23 Thread Alan Gauld
On 23/10/13 17:01, Glenn Lester wrote: I have come across the term "self" in a number of Python scripts and as a beginner to the language I am wondering if it has any specific meaning. Technically no, the name is arbitrary but self is used by (very strong) tradition. As to what it is used for

[Tutor] Want to keep to two decimal places for currency

2013-10-23 Thread Shelby Martin
I've looked online but I'm confused - I need to keep it so that the following program limits the output to two decimal places since it deals in currency. How do I incorporate that into my current code below? The textbook I'm using doesn't describe how to do that. Thanks in advance. #Challenge Ch

Re: [Tutor] Want to keep to two decimal places for currency

2013-10-23 Thread Alan Gauld
On 23/10/13 22:39, Shelby Martin wrote: I've looked online but I'm confused - I need to keep it so that the following program limits the output to two decimal places since it deals in currency. Its generally a bad idea to use floats when dealing with currency since they can introduce small err

Re: [Tutor] Want to keep to two decimal places for currency

2013-10-23 Thread Danny Yoo
On Wed, Oct 23, 2013 at 4:13 PM, Alan Gauld wrote: > On 23/10/13 22:39, Shelby Martin wrote: > >> I've looked online but I'm confused - I need to keep it so that the >> following program limits the output to two decimal places since it deals >> in currency. >> > > Its generally a bad idea to use f