Re: merits of Lisp vs Python

2006-12-26 Thread Lars Rune Nøstdal
On Sat, 23 Dec 2006 12:38:30 -0800, Fuzzyman wrote: > > Lars Rune Nøstdal wrote: >> On Fri, 08 Dec 2006 03:07:09 -0800, Mark Tarver wrote: >> >> > How do you compare Python to Lisp? What specific advantages do you >> > think that one has over the other? >> > >> > Note I'm not a Python person and

Re: module with a threading-like api that uses processes?

2006-12-26 Thread Gabriel Genellina
At Wednesday 27/12/2006 01:58, [EMAIL PROTECTED] wrote: I could have sworn someone was working on a module recently with a threading-like API that used subprocesses under the covers, but 10 minutes or so of googling didn't yield anything. Pointers appreciated. Perhaps this project? I just wro

Re: module with a threading-like api that uses processes?

2006-12-26 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > I could have sworn someone was working on a module recently with a > threading-like API that used subprocesses under the covers, but 10 minutes > or so of googling didn't yield anything. Pointers appreciated. http://www.python.org/dev/summary/2006-10-01_2006-10-15/#proc

module with a threading-like api that uses processes?

2006-12-26 Thread skip
I could have sworn someone was working on a module recently with a threading-like API that used subprocesses under the covers, but 10 minutes or so of googling didn't yield anything. Pointers appreciated. Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list

loose methods : Smalltalk asPython

2006-12-26 Thread Jan Theodore Galkowski
Hi. One of the things I'd like to do with Python is find a way to consistently implement Smalltalk's "loose methods". This is a capability whereby additional methods can be added dynamically to existing classes. In some respects, it's possible with Python. While "object" cannot be touched, it's

Re: Newbie: what is a usefull IDE for Python on Windows ?

2006-12-26 Thread [EMAIL PROTECTED]
Osiris wrote: > what is a usefull IDE for Python on Windows ? The Zeus IDE: http://www.zeusedit.com/python.html Jussi -- http://mail.python.org/mailman/listinfo/python-list

Re: Noobie: Open file -> read characters & multiply

2006-12-26 Thread WaterWalk
WaterWalk wrote: > WaterWalk wrote: > > gonzlobo wrote: > > > I've been using Python for a few days. It's such the perfect language > > > for parsing data! > > > > > > I really like it so far, but I'm having a hard time reading a file, > > > reading the first few hex characters & converting them t

Re: Noobie: Open file -> read characters & multiply

2006-12-26 Thread WaterWalk
WaterWalk wrote: > gonzlobo wrote: > > I've been using Python for a few days. It's such the perfect language > > for parsing data! > > > > I really like it so far, but I'm having a hard time reading a file, > > reading the first few hex characters & converting them to an integer. > > Once the char

Re: Noobie: Open file -> read characters & multiply

2006-12-26 Thread WaterWalk
gonzlobo wrote: > I've been using Python for a few days. It's such the perfect language > for parsing data! > > I really like it so far, but I'm having a hard time reading a file, > reading the first few hex characters & converting them to an integer. > Once the characters are converted to an inte

Re: How to depress the output of an external module ?

2006-12-26 Thread Carl Banks
Carl Banks wrote: > [EMAIL PROTECTED] wrote: > > After some trials I found that put "os.close(1)" before calling the > > function will depress the output. In fact, "os.close(1)" closed > > standard output, but I don't know how to open it again after the function's > > execution. > > Try this: > >

Re: How to suppress the output of an external module ?

2006-12-26 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > Hi, > > I'm writing a program which uses an external module written in C > and calls a function provided by the module to do my job. The > function produces a lot of output to the stdout. > > Is there a way to suppress the output produced by the function and > hence

Re: How to depress the output of an external module ?

2006-12-26 Thread Carl Banks
[EMAIL PROTECTED] wrote: > After some trials I found that put "os.close(1)" before calling the > function will depress the output. In fact, "os.close(1)" closed > standard output, but I don't know how to open it again after the function's > execution. Try this: fd = os.dup(1) os.close(1) sys.stdo

Re: Noobie: Open file -> read characters & multiply

2006-12-26 Thread Steven D'Aprano
On Tue, 26 Dec 2006 16:50:06 -0700, gonzlobo wrote: > I've been using Python for a few days. It's such the perfect language > for parsing data! > > I really like it so far, but I'm having a hard time reading a file, > reading the first few hex characters & converting them to an integer. > Once th

Re: Noobie: Open file -> read characters & multiply

2006-12-26 Thread Scott David Daniels
gonzlobo wrote: > I've been using Python for a few days. It's such the perfect language > for parsing data! > > I really like it so far, but I'm having a hard time reading a file, > reading the first few hex characters & converting them to an integer. > Once the characters are converted to an inte

Re: Persistent variables in python

2006-12-26 Thread Steven D'Aprano
On Tue, 26 Dec 2006 15:01:40 -0800, buffi wrote: >> def doStuff(some, arguments, may, *be, **required): >> try: >> doStuff.timesUsed += 1 >> except AttributeError: >> doStuff.timesUsed = 1 >> # ... special case for first call ... >> # ...common code... >

Re: How to depress the output of an external module ?

2006-12-26 Thread Steven D'Aprano
On Tue, 26 Dec 2006 03:21:57 -0800, Luis Armendariz wrote: > On Tuesday, 26.12.06 at 21:28, Steven D'Aprano wrote: >> >> # WARNING: untested >> def run_without_stdout(*args, **kwargs): >> function = args[0] >> args = args[1:] >> savestdout = sys.stdout >> sys.stdout = cStringIO.St

Noobie: Open file -> read characters & multiply

2006-12-26 Thread gonzlobo
I've been using Python for a few days. It's such the perfect language for parsing data! I really like it so far, but I'm having a hard time reading a file, reading the first few hex characters & converting them to an integer. Once the characters are converted to an integer, I'd like to write the d

Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread Frederic Rentsch
John Nagle wrote: > Felipe Almeida Lessa wrote: > >> On 26 Dec 2006 04:22:38 -0800, placid <[EMAIL PROTECTED]> wrote: >> >> >>> So do you want to remove "&" or replace them with "&" ? If you want >>> to replace it try the following; >>> >> I think he wants to replace them, but just t

Re: Persistent variables in python

2006-12-26 Thread Lee Harr
> Found out a quite fun way to store persistent variables in functions in > python. > > Is this concidered bad coding practice since I guess persistent > variables in functions are not meant to be? I am using is in one of my recent projects. I was thinking of it sort of like "static" variables

Re: Persistent variables in python

2006-12-26 Thread buffi
> I don't think so, since Python proudly says that functions are > first-class objects. > CherryPy does a similar thing to mark a method as "exposed". > > But perhaps I'd write the code this way to avoid an unneeded and > risky recursive call: > > def doStuff(some, arguments, may, *be, **required):

Re: Splitting lines from a database query

2006-12-26 Thread John Machin
Peter Machell wrote: > Scott David Daniels wrote: > > Peter Machell wrote: > >> ZeD wrote: > >> > >> Thanks very much ZeD. This will do what I need to. > >> The next step is to do some regex on the phone number to ensure it's > >> local and correct. How can I split these up so each value has a key

Re: Persistent variables in python

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 19:13, buffi wrote: def doStuff(): try: #Will throw exception if not set doStuff.timesUsed Is this concidered bad coding practice since I guess persistent variables in functions are not meant to be? I don't think so, since Python proudly says that functions are

Re: Splitting lines from a database query

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 18:57, Peter Machell wrote: for x in bar: fname = x[0] if fname == "": fname == "None" sname = x[1] if sname == "": sname == "None" print ""+fname+""+""+sname+"" Except that

Re: Splitting lines from a database query

2006-12-26 Thread Scott David Daniels
Peter Machell wrote: > I can almost do it this way: > > for x in bar: > fname = x[0] > if fname == "": > fname == "None" > sname = x[1] > if sname == "": > sname == "None" > > print ""+fname+""+""+sname+""

Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread Paul McGuire
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > At Monday 25/12/2006 21:24, Paul McGuire wrote: > >>For example, for all the complexity in writing Sudoku solvers, there are >>fewer than 3.3 million possible permutations of 9 rows of the digits 1-9, >>and far fewer

Re: Fuzzy string comparison

2006-12-26 Thread John Machin
Carsten Haese wrote: > On Tue, 2006-12-26 at 13:08 -0800, John Machin wrote: > > Wojciech Mula wrote: > > > Steve Bergman wrote: > > > > I'm looking for a module to do fuzzy comparison of strings. [...] > > > > > > Check module difflib, it returns difference between two sequences. > > > > and it's

Persistent variables in python

2006-12-26 Thread buffi
Found out a quite fun way to store persistent variables in functions in python. def doStuff(): try: #Will throw exception if not set doStuff.timesUsed ## #Insert stuff to do each time the function is called here ## doStuff.timesUsed+=1 print "Function call!" excep

Re: Splitting lines from a database query

2006-12-26 Thread Peter Machell
Scott David Daniels wrote: > Peter Machell wrote: >> ZeD wrote: >> >> Thanks very much ZeD. This will do what I need to. >> The next step is to do some regex on the phone number to ensure it's >> local and correct. How can I split these up so each value has a key? > > Well, you should try that,

Re: Fuzzy string comparison

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 18:08, John Machin wrote: Wojciech Mula wrote: > Steve Bergman wrote: > > I'm looking for a module to do fuzzy comparison of strings. [...] > > Check module difflib, it returns difference between two sequences. and it's intended for comparing text files, and is relatively

Re: Fuzzy string comparison

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 13:08 -0800, John Machin wrote: > Wojciech Mula wrote: > > Steve Bergman wrote: > > > I'm looking for a module to do fuzzy comparison of strings. [...] > > > > Check module difflib, it returns difference between two sequences. > > and it's intended for comparing text files, a

Re: Why does Python never add itself to the Windows path?

2006-12-26 Thread benc_nospam
Ross Ridge wrote: > Ben Sizer wrote: > > I've installed several different versions of Python across several > > different versions of MS Windows, and not a single time was the Python > > directory or the Scripts subdirectory added to the PATH environment > > variable. > > Personally, I hate Windows

Re: Type text global

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 13:57, Andreas Lysdal wrote: I'm a noob at python so.. I just want to know, is there a function to type text global not in the program but in other programs(like you where typing it). For example in a textbox, in a program like "cmd.exe" or "notebook.exe". I'm using windo

Re: keypressed() function

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 10:25, [EMAIL PROTECTED] wrote: I need a function (blocking or non-blocking) that tells me if a key has been pressed (even before it has been released etc.). Also, I would of course like to know _which_ key has been pressed. On Windows you can listen to the messages WM_KE

BeautifulSoup bug when ">>>" found in attribute value

2006-12-26 Thread John Nagle
This, which is from a real web site, went into BeautifulSoup: And this came out, via prettify: >>&linkurl;=/Europe/Spain/Madrid/Apartments/Offer/2408" /> BeautifulSoup seems to have become confused by the ">>>" within a quoted attribute value. It first parsed it right, but then stuck

Re: Fuzzy string comparison

2006-12-26 Thread John Machin
Wojciech Mula wrote: > Steve Bergman wrote: > > I'm looking for a module to do fuzzy comparison of strings. [...] > > Check module difflib, it returns difference between two sequences. and it's intended for comparing text files, and is relatively slow. Google "python levenshtein". You'll probably

Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread John Krukoff
On Tue, 2006-12-26 at 17:39 -0300, Gabriel Genellina wrote: > At Monday 25/12/2006 21:24, Paul McGuire wrote: > > >For example, for all the complexity in writing Sudoku solvers, there are > >fewer than 3.3 million possible permutations of 9 rows of the digits 1-9, > >and far fewer permutations tha

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread kwatch
Thanks Fredrik and Carsten, I'll try marshal module. > * Your code snippet is a statement, actually, a suite of statements. You > need to exec it, not eval it. > * You seem to think that eval'ing or exec'ing a code object will > magically capture its output stream. It won't. Oh, it's my mistake.

Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread Chris Mellon
On 12/26/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Monday 25/12/2006 21:24, Paul McGuire wrote: > > >For example, for all the complexity in writing Sudoku solvers, there are > >fewer than 3.3 million possible permutations of 9 rows of the digits 1-9, > >and far fewer permutations that m

Re: Splitting lines from a database query

2006-12-26 Thread Scott David Daniels
Peter Machell wrote: > ZeD wrote: > > Thanks very much ZeD. This will do what I need to. > The next step is to do some regex on the phone number to ensure it's > local and correct. How can I split these up so each value has a key? Well, you should try that, unless you intend to get the newsgrou

Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread Gabriel Genellina
At Monday 25/12/2006 21:24, Paul McGuire wrote: For example, for all the complexity in writing Sudoku solvers, there are fewer than 3.3 million possible permutations of 9 rows of the digits 1-9, and far fewer permutations that match the additional column and box constraints. Why not just comput

Re: Splitting lines from a database query

2006-12-26 Thread Peter Machell
ZeD wrote: > Peter Machell wrote: > >> I have an application where I need to take a query from an existing >> database and send it to a web api. > > [...] > >> There are always 5 values, but some are blank and some are 'None'. >> I'd like to split the lines so I get something resembling XML, lik

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 14:48 -0500, Carsten Haese wrote: > * Code objects come in two flavors: statements and expressions. > * exec can execute a 'statement' flavored code object. > * eval can evaluate an 'expression' flavored code object. > * Your code snippet is a statement, actually, a suite of s

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 11:15 -0800, [EMAIL PROTECTED] wrote: > Hi, > > It is possible to get bytecode from code object. > Reversely, is it possible to create code object from bytecode? > > ex. > ## python code (not a module) > pycode = '''\ > print "\n" > for item in items: > print "

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > It is possible to get bytecode from code object. > Reversely, is it possible to create code object from bytecode? > > ex. > ## python code (not a module) > pycode = '''\ > print "\n" > for item in items: > print "%s\n" % item > print "\n" > ''' > >

Mod_python

2006-12-26 Thread Lad
In my web application I use Apache and mod_python. I allow users to upload huge files( via HTTP FORM , using POST method) I would like to store the file directly on a hard disk and not to upload the WHOLE huge file into server's memory first. Can anyone suggest a solution? Thank you LB -- http:/

Q: How to generate code object from bytecode?

2006-12-26 Thread kwatch
Hi, It is possible to get bytecode from code object. Reversely, is it possible to create code object from bytecode? ex. ## python code (not a module) pycode = '''\ print "\n" for item in items: print "%s\n" % item print "\n" ''' ## compile it and get bytecode code = compile

Re: keypressed() function

2006-12-26 Thread robert
[EMAIL PROTECTED] wrote: > I need a function (blocking or non-blocking) that tells me if a key has > been pressed (even before it has been released etc.). Also, I would of > course like to know _which_ key has been pressed. > > I know that this probably does not exist in the Python library already

Google Custom Search Engine

2006-12-26 Thread robert . hundt
Hi, I created a Google Custom Search Engine for searching on: "Software / Compilers / Optimization" This is basically a regular full Google search giving preference to technical sites such as IEEE, ACM, citeseer, the Universities, news-group (this one included), commercial sites such as Intel,

Re: SPAM-LOW: Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread Duncan Booth
Andreas Lysdal <[EMAIL PROTECTED]> wrote: >> P.S. apos is handled specially as it isn't technically a >> valid html entity (and Python doesn't include it in its entity >> list), but it is an xml entity and recognised by many browsers so some >> people might use it in html. >> > Hey i fund this

Re: Why does Python never add itself to the Windows path?

2006-12-26 Thread robert
Ben Sizer wrote: > I've installed several different versions of Python across several > different versions of MS Windows, and not a single time was the Python > directory or the Scripts subdirectory added to the PATH environment > variable. Every time, I've had to go through and add this by hand, t

Re: perl better than python for users with disabilities?

2006-12-26 Thread [EMAIL PROTECTED]
Dan Jacobson wrote: > Can I feel even better about using perl vs. python, as apparently > python's dependence of formatting, indentation, etc. vs. perl's > "(){};" etc. makes writing python programs perhaps very device > dependent. Whereas perl can be written on a tiny tiny screen, and can > withst

Re: Fuzzy string comparison

2006-12-26 Thread Wojciech Muła
Steve Bergman wrote: > I'm looking for a module to do fuzzy comparison of strings. [...] Check module difflib, it returns difference between two sequences. -- http://mail.python.org/mailman/listinfo/python-list

Re: SPAM-LOW: Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread Andreas Lysdal
Duncan Booth skrev: > "Felipe Almeida Lessa" <[EMAIL PROTECTED]> wrote: > > >> On 26 Dec 2006 04:22:38 -0800, placid <[EMAIL PROTECTED]> wrote: >> >>> So do you want to remove "&" or replace them with "&" ? If you >>> want to replace it try the following; >>> >> I think he wants to

Fuzzy string comparison

2006-12-26 Thread Steve Bergman
I'm looking for a module to do fuzzy comparison of strings. I have 2 item master files which are supposed to be identical, but they have thousands of records where the item numbers don't match in various ways. One might include a '-' or have leading zeros, or have a single character missing, or a

Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread John Nagle
Felipe Almeida Lessa wrote: > On 26 Dec 2006 04:22:38 -0800, placid <[EMAIL PROTECTED]> wrote: > >> So do you want to remove "&" or replace them with "&" ? If you want >> to replace it try the following; > > > I think he wants to replace them, but just the invalid ones. I.e., > > This & this &

Re: Formatting a string to be a columned block of text

2006-12-26 Thread rzed
"Dave Borne" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Thanks, Paul. I didn't know about textwrap, that's neat. > > Leon, > so in my example change >> data1= [testdata[x:x+colwidth] for x in >> range(0,len(testdata),colwidth)] > to >> data1 = textwrap.wrap(testdata,colwidth) >> dat

Installing python.org distro over ActivePython?

2006-12-26 Thread Tom Plunket
Hey gang- I just ran into the fabled "Secure Sockets not enabled in ActivePython," and the ActiveState FAQ says I should just grab _ssl.pyd from "somewhere", offering up the python.org distribution as a possible source. I'm on 2.4 at this time, and python.org has what appears to be a considerably

Re: Newbie: what is a usefull IDE for Python on Windows ?

2006-12-26 Thread tac-tics
On Dec 26, 8:53 am, Larry Bates <[EMAIL PROTECTED]> wrote: > Osiris wrote: > > what is a usefull IDE for Python on Windows ? I am a happy user of jEDIT. -- http://mail.python.org/mailman/listinfo/python-list

Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread Duncan Booth
"Felipe Almeida Lessa" <[EMAIL PROTECTED]> wrote: > On 26 Dec 2006 04:22:38 -0800, placid <[EMAIL PROTECTED]> wrote: >> So do you want to remove "&" or replace them with "&" ? If you >> want to replace it try the following; > > I think he wants to replace them, but just the invalid ones. I.e., >

Type text global

2006-12-26 Thread Andreas Lysdal
Hey, I'm a noob at python so.. I just want to know, is there a function to type text global not in the program but in other programs(like you where typing it). For example in a textbox, in a program like "cmd.exe" or "notebook.exe". I'm using windows xp. Thanks! :) /Scripter47 -- http://m

Re: Newbie: what is a usefull IDE for Python on Windows ?

2006-12-26 Thread Larry Bates
Osiris wrote: > what is a usefull IDE for Python on Windows ? > > I saw Eric mentioned.. is that WinXP or Linux ? > > What does "everybody" use ? > > I was considering using old and very stable C-code in a new web > application via Python/Plone/Zope. I like pyscripter, available here: http://

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Duncan Booth
"Paul McGuire" <[EMAIL PROTECTED]> wrote: > By the way, this variable contains only 3 (very long) lines of text, > one for each paragraph. (Not immediately obvious after Usenet wraps > the text.) Usenet doesn't wrap text, all it has is a convention which suggests that people posting to usenet sh

PySchool Phase II

2006-12-26 Thread RobJ
PySchool Phase II I just wanted to thank everyone for filling out the survey a few months back for my PySchool graduate school project. I was able to capture a lot of good information from the community. For the people who mentioned to me that I should expand the "What Linux Operating System do yo

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > gettysburgAddress = """Four score and seven years ago... By the way, this variable contains only 3 (very long) lines of text, one for each paragraph. (Not immediately obvious after Usenet wraps the text.) -- Paul

Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread Felipe Almeida Lessa
On 26 Dec 2006 04:22:38 -0800, placid <[EMAIL PROTECTED]> wrote: > So do you want to remove "&" or replace them with "&" ? If you want > to replace it try the following; I think he wants to replace them, but just the invalid ones. I.e., This & this & that would become This & this & that No, i

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Dave Borne
Thanks, Paul. I didn't know about textwrap, that's neat. Leon, so in my example change > data1= [testdata[x:x+colwidth] for x in range(0,len(testdata),colwidth)] to > data1 = textwrap.wrap(testdata,colwidth) > data1 = [x.ljust(colwidth) for x in data1] oh and I made a mistake that double spaces i

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Dave Borne
On 26 Dec 2006 04:14:27 -0800, Leon <[EMAIL PROTECTED]> wrote: > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. Hi, Leon, For pu

Re: Formatting a string to be a columned block of text

2006-12-26 Thread Paul McGuire
"Leon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. > For

Re: How to depress the output of an external module ?

2006-12-26 Thread Sebastian 'lunar' Wiesner
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote > [EMAIL PROTECTED] wrote: >> >> I have tried your method, but I found it didn't work as expected. >> >> The output produced by the external function couldn't be depressed, >> but the "print " statement i wrote in python is depressed. It seems >> make cS

Re: How to depress the output of an external module ?

2006-12-26 Thread Stefan Schwarzer
Hi Luis, Luis Armendariz wrote: > There's no need for savestdout. There's a backup copy in sys.__stdout__ Depending on the code that ran before the call to the function run_without_stdout, sys.stdout may not be the same as sys.__stdout__ . Of course, you also have to be careful regarding threads

keypressed() function

2006-12-26 Thread [EMAIL PROTECTED]
I need a function (blocking or non-blocking) that tells me if a key has been pressed (even before it has been released etc.). Also, I would of course like to know _which_ key has been pressed. I know that this probably does not exist in the Python library already as a platform-independant abstract

Re: How to depress the output of an external module ?

2006-12-26 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > > I have tried your method, but I found it didn't work as expected. > > The output produced by the external function couldn't be depressed, > but the "print " statement i wrote in python is depressed. It seems > make cStringIO.StringIO() as a temporary replacement of sys.

Re: How to depress the output of an external module ?

2006-12-26 Thread André
[EMAIL PROTECTED] wrote: > Steven D'Aprano wrote: > > Try something like this: > > > > # WARNING: untested > > def run_without_stdout(*args, **kwargs): > > function = args[0] > > args = args[1:] > > savestdout = sys.stdout > > sys.stdout = cStringIO.StringIO() > > result = None

Re: How to stop program when threads is sleeping

2006-12-26 Thread Carsten Haese
On 25 Dec 2006 21:50:15 -0800, many_years_after wrote > While , there is something wrong in my expression. What I mean is the > thread will wait some time after doing some tasks. I want to know is > there any method to end the thread or make it out of execution of > waiting. I use time.sleep() to l

Re: Formatting a string to be a columned block of text

2006-12-26 Thread placid
Leon wrote: > Hi, > > I'm creating a python script that can take a string and print it to the > screen as a simple multi-columned block of mono-spaced, unhyphenated > text based on a specified character width and line hight for a column. > For example, if i fed the script an an essay, it would for

Re: some OT: how to solve this kind of problem in our program?

2006-12-26 Thread bearophileHUGS
For people that will read the posts in the future, there is a little bug (it doesn't change the output of this program): items = alist[:] Has to be: alist = alist[:] Sorry, bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

embedded python : can't get or set a variable

2006-12-26 Thread ycollet
Hello, I'm trying to write a program to send python statements to a python server via tcp and then get back results via a tcp connection. It nearly works ... but I'm totally lost with the embedded dictionary (I'm quite new to python). The first part of the server start the python interpreter via P

Re: How to depress the output of an external module ?

2006-12-26 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > Try something like this: > > # WARNING: untested > def run_without_stdout(*args, **kwargs): > function = args[0] > args = args[1:] > savestdout = sys.stdout > sys.stdout = cStringIO.StringIO() > result = None > try: > result = function(*args,

Re: Splitting lines from a database query

2006-12-26 Thread ZeD
Peter Machell wrote: > I have an application where I need to take a query from an existing > database and send it to a web api. [...] > There are always 5 values, but some are blank and some are 'None'. > I'd like to split the lines so I get something resembling XML, like this: > Frank > Spencer

Re: BeautifulSoup vs. loose & chars

2006-12-26 Thread placid
John Nagle wrote: > I've been parsing existing HTML with BeautifulSoup, and occasionally > hit content which has something like "Design & Advertising", that is, > an "&" instead of an "&". Is there some way I can get BeautifulSoup > to clean those up? There are various parsing options related to

Formatting a string to be a columned block of text

2006-12-26 Thread Leon
Hi, I'm creating a python script that can take a string and print it to the screen as a simple multi-columned block of mono-spaced, unhyphenated text based on a specified character width and line hight for a column. For example, if i fed the script an an essay, it would format the text like a news

Re: How to stop program when threads is sleeping

2006-12-26 Thread placid
many_years_after wrote: > Carsten Haese wrote: > > On Sun, 2006-12-24 at 22:55 -0800, many_years_after wrote: > > > Hi, pythoners: > > > > > > There is a problem I couldn't dispose. I start a thread in the my > > > program. The thread will do something before executing time.sleep(). > > > Wh

Splitting lines from a database query

2006-12-26 Thread Peter Machell
I have an application where I need to take a query from an existing database and send it to a web api. Here's a cut down version of my existing code: for foo in mssql.fetch_array(); bar = foo[2] #trims the first result which we don't use for x in bar: for y in x

Re: How to depress the output of an external module ?

2006-12-26 Thread Luis Armendariz
On Tuesday, 26.12.06 at 21:28, Steven D'Aprano wrote: > > # WARNING: untested > def run_without_stdout(*args, **kwargs): > function = args[0] > args = args[1:] > savestdout = sys.stdout > sys.stdout = cStringIO.StringIO() > result = None > try: > result = function(*

Re: How to depress the output of an external module ?

2006-12-26 Thread Steven D'Aprano
On Tue, 26 Dec 2006 15:49:10 +0800, [EMAIL PROTECTED] wrote: > Hi, > > I'm writing a program which imports an external module writing in C and > calls a function provided by the module to do my job. But the method > produces > a lot of output to the stdout, and this consumes most of the running

Re: Can Python help?

2006-12-26 Thread Gregor Horvath
Lad schrieb: > On my website I allow users to upload files. I would like a user to see > how much time is left before a file is uploaded. So, I would like to > have a progress bar during a file uploading. Can Python help me with > that?Or how can be a progress bar made? > Thank you for ideas. > L