Re: [Tutor] output formatting

2009-04-27 Thread Lie Ryan
Matt Domeier wrote: Hi Wayne, Yes, that should work perfectly, but it is in writing files that I'm having the problem. I'm still very new to python, so I only know to use something like filename.write(str(listname)) to write my list to a file.. Is there a straightforward method of combining th

Re: [Tutor] How to run a .py file or load a module?

2009-04-27 Thread spir
Le Sun, 26 Apr 2009 22:35:36 +0100, Dayo Adewunmi s'exprima ainsi: > How can I > > a) Open my shell, and do something like: $ python countdown.py > but have it take an argument and pass it to the function, and execute. When your code is (nicely) organised as a set of funcs or class definitio

Re: [Tutor] Threading...

2009-04-27 Thread Kent Johnson
On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: > you are making > a IO-bound app, so threading doesn't buy you anything in performance and > gives a big headache in data protection Please explain. Presumably the single-threaded app is not IO-bound. Adding threads can push it to the point of

Re: [Tutor] Threading...

2009-04-27 Thread A.T.Hofkamp
Kent Johnson wrote: On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: you are making a IO-bound app, so threading doesn't buy you anything in performance and gives a big headache in data protection Please explain. Presumably the single-threaded app is not IO-bound. Adding threads can push i

Re: [Tutor] Threading...

2009-04-27 Thread Kent Johnson
On Mon, Apr 27, 2009 at 9:29 AM, A.T.Hofkamp wrote: > Kent Johnson wrote: >> >> On Mon, Apr 27, 2009 at 2:46 AM, A.T.Hofkamp wrote: >>> >>> you are making >>> a IO-bound app, so threading doesn't buy you anything in performance and >>> gives a big headache in data protection Perhaps I misinterpr

[Tutor] How many types of the constructor

2009-04-27 Thread sudhanshu gautam
when we work on the oops in the python then we have to pass the first parameter as a self then the value of the other parameters . for example: class Student: def __init__(self,name): self.name=name print 'The name is',self.name a=student('sudhanshu') a is an object of the student class so __init

Re: [Tutor] How many types of the constructor

2009-04-27 Thread Noufal Ibrahim
Greetings Sudanshu, sudhanshu gautam wrote: when we work on the oops in the python then we have to pass the first parameter as a self then the value of the other parameters . Well, not explicitly. If you're familiar with OOPS in C++, self is analogous to the "this" pointer there. Also, you ne

Re: [Tutor] How many types of the constructor

2009-04-27 Thread Emile van Sebille
sudhanshu gautam wrote: Now If I placed the name of the constructor rather than the __init__ __baba___ so will it also work as a constructor or constructor has specified already if yes then give me list of them I'm not sure I parsed your question as you intended, but __init__ is pretty much

Re: [Tutor] How many types of the constructor

2009-04-27 Thread spir
Le Mon, 27 Apr 2009 22:38:30 +0530, sudhanshu gautam s'exprima ainsi: > Now If I placed the name of the constructor rather than the __init__ > __baba___ so will it also work as a constructor or constructor has specified > already if yes then give me list of them Actually __init__ is not the con

Re: [Tutor] How to run a .py file or load a module?

2009-04-27 Thread Alan Gauld
Offlist response... Nice answer Denis, you neatly covered all the loose ends from previous answers that I was just about to pick up on! :-) "spir" wrote in message news:20090427101523.5fc09...@o... Le Sun, 26 Apr 2009 22:35:36 +0100, Dayo Adewunmi s'exprima ainsi: How can I a) Open my she

Re: [Tutor] Lists in a file

2009-04-27 Thread David Holland
Thanks for all the suggestions.  I will have to try this. --- On Sun, 26/4/09, Kent Johnson wrote: From: Kent Johnson Subject: Re: [Tutor] Lists in a file To: "Robert Berman" Cc: "David Holland" , "tutor python" Date: Sunday, 26 April, 2009, 8:04 PM On Sun, Apr 26, 2009 at 2:18 PM, Robert B

Re: [Tutor] How many types of the constructor

2009-04-27 Thread Alan Gauld
"sudhanshu gautam" wrote Now If I placed the name of the constructor rather than the __init__ __baba___ so will it also work as a constructor or constructor has specified already if yes then give me list of them Unlike some other OOP languages Python only has one constructor (OK As Denis po

Re: [Tutor] How to run a .py file or load a module?

2009-04-27 Thread Alan Gauld
"Alan Gauld" wrote Offlist response... Oops, not offlist! Just as well I didn't say anything offensive! :-) Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-27 Thread Dan Liang
Hi Bob, Shantanoo, Kent, and tutors, Thank you Bob, Shantanoo, Kent for all the nice feedback. Exception handling, the concept of states in cs, and the use of the for loop with offset helped a lot. Here is the code I now have, based on your suggestions, and it does what I need: ListLines = [ line