Re: Making a persistent HTTP connection

2005-11-14 Thread Alan Kennedy
[David Rasmussen] >> I use urllib2 to do some simple HTTP communication with a web server. >> In one "session", I do maybe 10-15 requests. It seems that urllib2 >> opens op a connection every time I do a request. Can I somehow make it >> use _one_ persistent connection where I can do multiple GE

Re: Proposal for adding symbols within Python

2005-11-14 Thread Björn Lindström
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Why does the byte string "\x6f\x70\x65\x6e\x65\x64" have intrinsic > meaning when the int 0 doesn't? It certainly doesn't mean anything to > non-English speakers. > > If all you want is human readable byte strings, then just use them: > > class MyFile:

Re: Making a persistent HTTP connection

2005-11-14 Thread Alan Kennedy
[David Rasmussen] >> I use urllib2 to do some simple HTTP communication with a web server. >> In one "session", I do maybe 10-15 requests. It seems that urllib2 >> opens op a connection every time I do a request. Can I somehow make it >> use _one_ persistent connection where I can do multiple GET->

Searching date and and time from a text file

2005-11-14 Thread masudtarek
Hi, I am new in Python programming. Can anybody give me any idea about how to detect more than one date and time (like 11/11/2005 , 10-12-2006, 12:30 etc) from a text file and keep them in a list. -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching date and and time from a text file

2005-11-14 Thread Daniel Schüle
[EMAIL PROTECTED] wrote: > Hi, I am new in Python programming. Can anybody give me any idea about > how to detect more than one date and time (like 11/11/2005 , > 10-12-2006, 12:30 etc) from a text file and keep them in a list. well first we read the file src = file("/your/file").read() then we

Re: Parse file into array

2005-11-14 Thread Leif K-Brooks
amfr wrote: > I was wondering how i could parse the contents of a file into an array. > the file would look something like this: > > gif:image/gif > html:text/html > jpg:image/jpeg > ... > > As you can see, it contains the mime type and the file extension > seperated by commas, 1 per line. I wa

Re: Searching date and and time from a text file

2005-11-14 Thread masudtarek
Thanks. It was like 911 -- http://mail.python.org/mailman/listinfo/python-list

Re: Parse file into array

2005-11-14 Thread amfr
Thanks a lot. The webserver I am writing works now :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Parse file into array

2005-11-14 Thread Leif K-Brooks
Leif K-Brooks wrote: > line = line.rsplit('\r\n') Er, that should be line.rstrip, not line.rsplit. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tix BUG? Where to submit?

2005-11-14 Thread Martin v. Löwis
Ron wrote: > Surprising to myself, this was all that it took to make this work. So I'm > not sure why this method was left out. Could it have been an oversight? It could be an oversight. More likely, it was not originally there when the underlying tix library was developed, and only added to t

Re: Searching date and and time from a text file

2005-11-14 Thread davideugenewarren
[EMAIL PROTECTED] wrote: > Hi, I am new in Python programming. Can anybody give me any idea about > how to detect more than one date and time (like 11/11/2005 , > 10-12-2006, 12:30 etc) from a text file and keep them in a list. http://docs.python.org/lib/bltin-file-objects.html http://docs.pytho

how to convert between type string and token

2005-11-14 Thread enas khalil
hello all when i run the code : # -*- coding: cp1256 -*-from nltk.tagger import *from nltk.corpus import brownfrom nltk.tokenizer import WhitespaceTokenizer # Tokenize ten texts from the Brown Corpustrain_tokens = []xx=Token(TEXT=open('fataha2.txt').read())WhitespaceTokenizer().tokenize(xx)f

Re: more newbie help needed

2005-11-14 Thread Steve Holden
john boy wrote: [top-posting corrected] > > Steve Holden <[EMAIL PROTECTED]> wrote:john boy wrote: > >>using the following program: >> >>fruit = "banana" >>index = 0 >>while index < len (fruit): >>letter = fruit[index-1] >>print letter >>index= index -1 >> >>this program is supposed to spell "ban

Re: [Tutor] how to convert between type string and token

2005-11-14 Thread Danny Yoo
On Mon, 14 Nov 2005, enas khalil wrote: > hello all [program cut] Hi Enas, You may want to try talking with NTLK folks about this, as what you're dealing with is a specialized subject. Also, have you gone through the tokenization tutorial in: http://nltk.sourceforge.net/tutorial/tok

Re: how to convert between type string and token

2005-11-14 Thread Gary Herron
This is not really a Python question, but a question on how to use the nltk package. I've never used, installed nor even seen that package, so of course I can't answer your question, but I do have a suggestion. A quick goggle finds a web page for nltk: http://nltk.sourceforge.net/. Is that where

Re: compare list

2005-11-14 Thread Brian van den Broek
Ben Bush said unto the world upon 2005-11-14 05:51: > I have four lists: > lisA=[1,2,3,4,5,6,9] > lisB=[1,6,5] > lisC=[5,6,3] > lisD=[11,14,12,15] > how can I write a function to compare lisB, lisC and lisD with lisA, if they > share two continuous elements (the order does not matter), then return

Re: Pregunta sobre python

2005-11-14 Thread J Correia
Para Windows: import win32api handle = win32api.OpenProcess(1, False, pid_del_proceso) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) "Yves Glodt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andres de la Cuadra wrote: > > Hola, me llamo Andres de la cuadra,

Re: how to start a process and get it's pid?

2005-11-14 Thread J Correia
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Fredrik Lundh wrote: > > Daniel Crespo wrote: > >>os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe") > >>>1944 > >> > >>I don't get the correct PID. > >> > >>When I do os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe") >

Re: circle and point

2005-11-14 Thread Robert Kern
Ben Bush wrote: > is there any python code doing this: > there are two line segments (2x+y-1=0 with the coordinates of two ending > points are (1,-1) and (-1,3); > x+y+6=0 with the coordinates of two ending points are (-3,-3) and > (-4,-2);). They extend and when they meet each other, stop extendin

Where can I find an example that uses FTP standard library?

2005-11-14 Thread QuadriKev
I am fairly new to programming in Python. There are a number of cases where I would like to see examples of programs written. I like to write them on Windows and in some cases put them on my Linux server to do something useful. I am also interested in using Telnet to check services and things on

best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is indeed fixed. Being in a hurry, I originally used a q&d hack...: if sys.platform in ('linux2', 'da

Re: modifying small chunks from long string

2005-11-14 Thread MackS
Thank you all for your great help. One of the few things better than python is the knowledgeable community around it. : ) Regards, Mack -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Alex Martelli
Brian van den Broek <[EMAIL PROTECTED]> wrote: > Ben Bush said unto the world upon 2005-11-14 05:51: > > I have four lists: > > lisA=[1,2,3,4,5,6,9] > > lisB=[1,6,5] > > lisC=[5,6,3] > > lisD=[11,14,12,15] > > how can I write a function to compare lisB, lisC and lisD with lisA, if they > > share t

Re: compare list

2005-11-14 Thread Duncan Smith
Brian van den Broek wrote: > Ben Bush said unto the world upon 2005-11-14 05:51: > >> I have four lists: >> lisA=[1,2,3,4,5,6,9] >> lisB=[1,6,5] >> lisC=[5,6,3] >> lisD=[11,14,12,15] >> how can I write a function to compare lisB, lisC and lisD with lisA, >> if they >> share two continuous elements

Re: Proposal for adding symbols within Python

2005-11-14 Thread Steven D'Aprano
Björn Lindström wrote: > So, I guess no one read my explanation of why this an issue about more > than implementing enums (which is fairly trivial, as we have seen). I read it. I don't see that it is an issue, and I especially don't see why it is relevent to Pierre's usage of symbols. In your

Re: modifying small chunks from long string

2005-11-14 Thread Steven D'Aprano
Tony Nelson wrote: > >Can I get over this performance problem without reimplementing the > >whole thing using a barebones list object? I though I was being "smart" > >by avoiding editing the long list, but then it struck me that I am > >creating a second object of the same size when I put the modi

Re: Where can I find an example that uses FTP standard library?

2005-11-14 Thread Grig Gheorghiu
I have some code that looks something like this: from ftplib import FTP ftp = FTP() # connect and login ftp.connect(server_name) ftp.login(user_name, password) cmd = "STOR %s" % filename #"ASCII transfer" l = open(filename) ftp.storlines(cmd, l) #"BIN transfer" l = open(filename, 'rb') ftp.storbi

Re: Proposal for adding symbols within Python

2005-11-14 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 14 Nov 2005 17:15:04 +0100, Pierre Barbier de Reuille wrote: > > The key point that, I think, you misunderstand is that symbols are > > not *variables* they are *values*. > > Python doesn't have variables. It has names and objects. That seems t

Re: Proposal for adding symbols within Python

2005-11-14 Thread Ben Finney
Björn Lindström <[EMAIL PROTECTED]> wrote: > So, I guess no one read my explanation of why this an issue about > more than implementing enums (which is fairly trivial, as we have > seen). I read it. I see that something more than enums is being asked for. What I don't see is a use case where this

Post/View Open Source Jobs

2005-11-14 Thread Superior Staffing Solutions
Post/View Open Source Jobs http://groups.yahoo.com/group/opensourcejobs -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Steven D'Aprano
Not sure if I should start a new thread or not, but since this is closely related, I'll just leave it as is. Alex Martelli wrote: > Having fixed a memory leak (not the leak of a Python reference, some > other stuff I wasn't properly freeing in certain cases) in a C-coded > extension I maintain,

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Not sure if I should start a new thread or not, but > since this is closely related, I'll just leave it as is. > > Alex Martelli wrote: > > > Having fixed a memory leak (not the leak of a Python reference, some > > other stuff I wasn't properly freei

Re: Installing tkinter with Python 2.4.2 on FC4

2005-11-14 Thread Paul Watson
Paul Watson wrote: > I cannot yet get tkinter working on 2.4.2. I have installed the tk rpms > from FC4. I have checked to see that TKPATH is available in > Modules/Setup. > > How can I verify that I have tcl/tk installed correctly and it is the > correct version (8+)? Surely, there must be

Re: compare list

2005-11-14 Thread Ben Bush
what does the following code mean?  if item in list2:                        if item + 1 in list1 and item + 1 in list2:  On 11/14/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: Ben Bush said unto the world upon 2005-11-14 05:51:> I have four lists:> lisA=[1,2,3,4,5,6,9] > lisB=[1,6,5]> lisC=[5

Re: compare list

2005-11-14 Thread Ben Bush
Hijacking Brian's response since my newsserver never god Ben's originalrequest...:I would program this at a reasonably high abstraction level, based on sets -- since you say order doesn't matter, sets are more appropriatethan lists anyway.  For example:def two_cont_in_common(x, y):   common = set(

about invalid syntax

2005-11-14 Thread Ben Bush
When I run scripts in PythonWin, sometimes will get the message of invalid syntax error. How can I check which error I made? For example, in VB, you might got the wrong place highlighted and help message too.-- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Ben Bush
[snip]That's potentially very expensive for large lists, although simplyconverting the lists to sets should give a significant speed up.  I think the following is *possibly* as good a way as any.>>> def compare(list1, list2):   intersection = sorted(list(set(list1) & set(list2)))   for i i

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Neal Norwitz
Alex Martelli wrote: > > So, I thought I'd turn to the "wisdom of crowds"... how would YOU guys > go about adding to your automated regression tests one that checks that > a certain memory leak has not recurred, as cross-platform as feasible? > In particular, how would you code _memsize() "cross-pl

Re: about invalid syntax

2005-11-14 Thread adDoc's networker Phil
. maybe you could separate your code into parts { python std, pythonwin-specific}, and then use a debugger to know most of the problem sources? (I'm not familiar with pythonwin, I assume it's a superset of python std) .On 11/14/05, Ben Bush <[EMAIL PROTECTED] > wrote:When I run scripts in PythonWin

Re: XML Tree Discovery (script, tool, __?)

2005-11-14 Thread George Sakkis
I somehow missed this reply posted two weeks ago. <[EMAIL PROTECTED]> wrote: > "Neat, though non-trivial XSLT makes my head spin." > > Well, you don't have to know XSLT at all to use the Examplotron > transform, although I can understand wanting to understand and hack > what you're using. > > "Ju

Re: compare list

2005-11-14 Thread Brian van den Broek
Ben Bush said unto the world upon 2005-11-14 23:20: > > On 11/14/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > >>Ben Bush said unto the world upon 2005-11-14 05:51: >> >>>I have four lists: >>>lisA=[1,2,3,4,5,6,9] >>>lisB=[1,6,5] >>>lisC=[5,6,3] >>>lisD=[11,14,12,15] >>>how can I write

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread MrJean1
My suggestion would also be to use sbrk() as it provides a high-water mark for the memory usage of the process. Below is the function hiwm() I used on Linux (RedHat). MacOS X and Unix versions are straigthforward. Not sure about Windows. /Jean Brouwers #if _LINUX #include size_t hiwm (void)

Re: about invalid syntax

2005-11-14 Thread Ben Bush
On 11/14/05, adDoc's networker Phil <[EMAIL PROTECTED]> wrote: . maybe you could separate your code into parts { python std, pythonwin-specific},and then use a debugger to know most of the problem sources? (I'm not familiar with pythonwin, I assume it's a superset of python std) . On 11/14/05, Be

Re: compare list

2005-11-14 Thread Ben Bush
  Hi Brian, regarding "if item + 1 in list1 and item + 1 in list2:", my understanding is this will check whether the following item in each list is the same. How does the code permit the situation that the order does not matter? For example, for lisA and lisB, the comparison is true and the two lis

Re: compare list

2005-11-14 Thread Shi Mu
> Hey Ben, > > first, as expected, the other two answers you received are better. :-) > > Sets are much better optimized for things like membership testing than > are lists. I'm not competent to explain why; indeed, I keep > overlooking them myself :-( > > Unfortunately, the indents got screwed up

Re: Copyright [was Re: Python Obfuscation]

2005-11-14 Thread garabik-news-2005-05
Erik Max Francis <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers wrote: > >> Depends on the country's laws and the exact agreement. > > Work for hire is part of the Berne convention. > According to recent (2003) Slovak copyright law, ONLY the individual authors own the copyright, and they cann

Re: compare list

2005-11-14 Thread Ben Bush
On 11/14/05, Ben Bush <[EMAIL PROTECTED]> wrote: Hijacking Brian's response since my newsserver never god Ben's originalrequest...:I would program this at a reasonably high abstraction level, based on sets -- since you say order doesn't matter, sets are more appropriatethan lists anyway.  For e

<    1   2