Re: [Tutor] reading from stdin

2005-03-02 Thread Nick Lunt
Thanks to everyone who helped me with this. It's certainly given me something to think about :) Cheers Nick . On Tue, 2005-03-01 at 23:13 -0600, David Rock wrote: > * Nick Lunt <[EMAIL PROTECTED]> [2005-03-01 22:23]: > > On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote: > > > > > > > > unle

Re: [Tutor] reading from stdin

2005-03-02 Thread Nick Lunt
Hi Hugo, many thanks for pointing that out. It all helps :) Thanks again, Nick . On Tue, 2005-03-01 at 17:35 -0600, Hugo GonzÃlez Monteverde wrote: > Everypne else has answered pretty muh about this. I just want to add > that if you want to read noncanonically (less thana line ending in "\n"

Re: [Tutor] How to use threads ?

2005-03-02 Thread Terry Carroll
On Tue, 1 Mar 2005, Mark Kels wrote: > Can anyone give me a very simple example on thread programming ? I don't think a simple example is possible, given that threads are inherently for slightly more complex processing than you ordinarily do. That being said, here's an example. This is a made-

Re: [Tutor] open a socket from a named file on linux

2005-03-02 Thread dm
On Sun, 2005-02-27 at 17:18 -0600, dm wrote: > Hello, I am trying to open a socket connection to a named file on my > computer and can not seem to get it working. Any help or advice would > be great. solution use what are called unix domain sockets, in python they are accessed like this s = s

[Tutor] Re: Help- Simple recursive function to build a list

2005-03-02 Thread Kent Johnson
actuary77 wrote: Kent Johnson wrote: >>> def rec(n,alist=[]): ... _nl=alist[:] ... print n,_nl ... if n == 0: ... print n,_nl ... return _nl ... else: ... _nl=_nl+[n] ... return rec(n-1,_nl) ... >>> _nl = rec(4) 4 [] 3 [4] 2 [4, 3] 1 [4, 3,

[Tutor] Re: Online Programming Contest (Python solutions accepted)

2005-03-02 Thread Shitiz Bansal
Hi, some questions need to be addressed. First, is execution time a factor, bcos admittedly python sols r much slowere than c/c++. second, wats the exact conf of python installed on machines checking our sols. i.e. which modules r allowed n which r not. shitiz --- Sridhar <[EMAIL PROTECTED]> wrote:

[Tutor] Re: Python Online Programming Contest

2005-03-02 Thread Varun Soundararajan
Hi, The results of OPC (online programming contest) is out. The statistics of python usage is available at http://www.samhita.info/opc/status.php. Regards, -OPC Team ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to use threads ?

2005-03-02 Thread Mark Kels
On Tue, 1 Mar 2005 12:25:37 -0800 (PST), Shitiz Bansal <[EMAIL PROTECTED]> wrote: > > Here is a simple program > > class abc(threading.Thread): > def __init__(self): > threading.Thread.__init__(self) > self.x=1 etc. etc. > self.cont_flag=1 > def run(self): >

[Tutor] Threaded persistance?

2005-03-02 Thread Gwyn Evans
Hi, New to Python, but with Java background I'm interested in comments/suggestions for something I'm trying... I've got a series of events (basically a dictionary of a few key:value pairs) which I'd like to forward onto a web service. That should be no problem, but I'm investigating what I c

Re: [Tutor] Threaded persistance?

2005-03-02 Thread Kent Johnson
Gwyn Evans wrote: Hi, New to Python, but with Java background I'm interested in comments/suggestions for something I'm trying... I've got a series of events (basically a dictionary of a few key:value pairs) which I'd like to forward onto a web service. That should be no problem, but I'm inves

[Tutor] Better Search and replace method

2005-03-02 Thread Ron Nixon
I'm trying to figure out a better solution to do multiple search and replaces in a text file without having to type: import re s = open('filename') re.sub('vaule1','value2',s) re.sub('vaule3','value4',s) etc I've tried putting all the vaules in a list and doing the replace, but came up short. An

Re: [Tutor] Threaded persistance?

2005-03-02 Thread Gwyn Evans
On Wed, 02 Mar 2005 15:53:17 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: > Gwyn Evans wrote: > > Hi, > > New to Python, but with Java background I'm interested in > > comments/suggestions for something I'm trying... > > > > I've got a series of events (basically a dictionary of a few > > ke

[Tutor] Re: Threaded persistance?

2005-03-02 Thread Gwyn Evans
On Wed, 2 Mar 2005 20:34:18 +, Gwyn Evans <[EMAIL PROTECTED]> wrote: > I had a look at using ZODB but hit problems when trying to have two > connections to the same FileStorage DB, but a second look at things > suggested that dbm might well do what I need, if I ensure only one > thread at a ti

Re: [Tutor] How to use threads ?

2005-03-02 Thread Terry Carroll
On Wed, 2 Mar 2005, Mark Kels wrote: > The only problem is that when I try to do it my thread doesnt closes. > When does a thread closes ? You got me. That's what I meant when I wrote "calls to t.isAlive() returned True long after the thread referred to had finished up and put out its final [shu

Re: [Tutor] Better Search and replace method

2005-03-02 Thread Alan Gauld
> I'm trying to figure out a better solution to do > multiple search and replaces in a text file without > having to type: > import re > s = open('filename') s = open(...).read() # I assume? > re.sub('vaule1','value2',s) > re.sub('vaule3','value4',s) > I've tried putting all the vaules in a li

Re: [Tutor] Better Search and replace method

2005-03-02 Thread Kent Johnson
Ron Nixon wrote: I'm trying to figure out a better solution to do multiple search and replaces in a text file without having to type: import re s = open('filename') re.sub('vaule1','value2',s) re.sub('vaule3','value4',s) etc I've tried putting all the vaules in a list and doing the replace, but c

Re: [Tutor] How to use threads ?

2005-03-02 Thread Shitiz Bansal
The thread finishes when: 1.The run method finishes. 2.In case of the loop- you may - >>> import threading >>> class abc(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.cont_flag=1 def run(self): while

[Tutor] slow html generation code

2005-03-02 Thread Luis N
This code seems a little slow, is there anything in particular that jumps out as being not quite right. The idea is that a file is opened that contains path names to other files, that are appended and outputed into a directory of choice. I plan to move this off the filesystem into a database when

Re: [Tutor] slow html generation code

2005-03-02 Thread Sean Perry
Luis N wrote: This code seems a little slow, is there anything in particular that jumps out as being not quite right. The idea is that a file is opened that contains path names to other files, that are appended and outputed into a directory of choice. I plan to move this off the filesystem into a d

Re: [Tutor] slow html generation code

2005-03-02 Thread Danny Yoo
On Wed, 2 Mar 2005, Luis N wrote: > This code seems a little slow, is there anything in particular that > jumps out as being not quite right. Hi Luis, Some comments: You have an empty 'except' exception-handling block in the code: ## try: for i in files:

[Tutor] Re: How to read unicode strings from a binary file and display them as plain ascii?

2005-03-02 Thread Javier Ruere
R. Alan Monroe wrote: R. Alan Monroe wrote: I started writing a program to parse the headers of truetype fonts to examine their family info. But I can't manage to print out the strings without the zero bytes in between each character (they display as a black block labeled 'NUL' in Scite's output pa

Re: [Tutor] slow html generation code

2005-03-02 Thread Kent Johnson
Danny Yoo wrote: It also makes it easier to see a possible bug in the code: the last few lines in the 'for' loop look suspicious: ## txt = textile(tmp) + '' t = Template(txt) s = t.safe_substitute(title='Web-siter: %s' % i[:-5]) output = open(page, 'w') o