Problem: using signal.alarm() to stop a run-away os.system() command

2005-05-27 Thread mkent
I'm trying to use signal.alarm to stop a run-away os.system command. Can anyone exlain the following behavior? Given following the trivial program: import os import signal def timeoutHandler(signum, frame): print "Timeout" raise ValueError signal.signal(signal.SIGALRM, timeoutHandler)

Get number of lines in file

2005-05-27 Thread ssmith579
I have read in a file and need to get the number of lines. cpn_file = open('Central Part number list.txt') cpn_version = cpn_file.read().split('\n') I want to know the number of elements in cpn_version. -- http://mail.python.org/mailman/listinfo/python-list

Re: distutils, 'scripts' and Windows

2005-05-27 Thread John Roth
"George van den Driessche" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi folks, > > I'm looking at packaging a project I'm working on using distutils. The > project is for Windows and contains a COM server which needs registration, > so the installer needs to be a little more

Re: Case Sensitive, Multiline Comments

2005-05-27 Thread John Roth
"Elliot Temple" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > One other interesting thing about case sensitivity I don't think anyone > has mentioned: in Python keywords are all lowercase already (the way I > want to type them). In some other languages, they aren't... Not qui

Re: regexp for sequence of quoted strings

2005-05-27 Thread gry
PyParsing rocks! Here's what I ended up with: def unpack_sql_array(s): import pyparsing as pp withquotes = pp.dblQuotedString.setParseAction(pp.removeQuotes) withoutquotes = pp.CharsNotIn('",') parser = pp.StringStart() + \ pp.Word('{').suppress() + \ pp.

[pysqlite 2.0.2] UnicodeDecodeError: 'utf8' codec can't decode bytes in position 44-45: invalid data

2005-05-27 Thread F. GEIGER
A fetchall() call causes the above error. There must be some non-utf8 chars in the table in question and - indeed - there very likely are: The table contains pathnames of files on the harddisk of a German "speaking" PC. What I have already done to try to overcome this is: - Inserted "# coding: iso

Re: Get number of lines in file

2005-05-27 Thread Elliot Temple
On May 27, 2005, at 12:17 PM, [EMAIL PROTECTED] wrote: > I have read in a file and need to get the number of lines. > > cpn_file = open('Central Part number list.txt') > cpn_version = cpn_file.read().split('\n') > > I want to know the number of elements in cpn_version. Could you use: co

[pysqlite] Equivalent for SHOW TABLES?

2005-05-27 Thread F. GEIGER
For now, the names of the tables, the app knows of, are added into an internal list, when the app is started. Then, when queries fail, the app knoes that it has to create them. It would be nice somehow to be able to ask the database what tables it contains. Is anyone doing this that way? How do yo

Re: Problem: using signal.alarm() to stop a run-away os.system() command

2005-05-27 Thread Jp Calderone
On 27 May 2005 12:09:39 -0700, [EMAIL PROTECTED] wrote: >I'm trying to use signal.alarm to stop a run-away os.system command. >Can anyone exlain the following behavior? > >Given following the trivial program: > >import os >import signal > >def timeoutHandler(signum, frame): >print "Timeout" >

Re: [Twisted-Python] xmlrpc deferred

2005-05-27 Thread Jp Calderone
On Fri, 27 May 2005 22:28:06 +0300, Catalin Constantin <[EMAIL PROTECTED]> wrote: >Hi there, > >I have the following xmlrpc method: > >class FeederResource(xmlrpc.XMLRPC): >def __init__(self): >xmlrpc.XMLRPC.__init__(self) >self.feeder=Feeder() > >de

Re: [Twisted-Python] xmlrpc deferred

2005-05-27 Thread Jp Calderone
Err woops. Wrong list, sorry. Jp -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem: using signal.alarm() to stop a run-away os.system() command

2005-05-27 Thread mkent
Thanks, that's the kind of on-target info I needed. Now, shouldn't there be some kind of mention of this limitation in the docs? -- http://mail.python.org/mailman/listinfo/python-list

Re: Get number of lines in file

2005-05-27 Thread ssmith579
Thanks! I was trying len(cpn_version) and that didn't work. -- http://mail.python.org/mailman/listinfo/python-list

Re: evaluated function defaults: stored where?

2005-05-27 Thread David Isaac
Alan Isaac wrote: > Default parameter values are evaluated once when the function definition is > executed. Where are they stored? ... Where is this documented? Forgive any poor phrasing: I'm not a computer science type. At http://www.network-theory.co.uk/docs/pytut/tut_26.html we read: "The execu

Re: evaluated function defaults: stored where?

2005-05-27 Thread Jp Calderone
On Fri, 27 May 2005 21:07:56 GMT, David Isaac <[EMAIL PROTECTED]> wrote: >Alan Isaac wrote: >> Default parameter values are evaluated once when the function definition >is >> executed. Where are they stored? ... Where is this documented? > >Forgive any poor phrasing: I'm not a computer science type

[ANN] XPN 0.4.6

2005-05-27 Thread Nemesis
XPN (X Python Newsreader XPN) is a multi-platform newsreader with Unicode support. It has features like scoring/actions, X-Face and Face decoding, muting of quoted text, newsrc import/export, find article and search in the body, spoiler char/rot13, random taglines, and configurable attribution line

Re: Python/Excel AddIn (was:Re: Does Python have a Template::Extract equivalent from Perl's CPAN)

2005-05-27 Thread combinational.logic $ soc-ip.com
Thanks Paul! When I get a chance I'll mess around with Py + Excel as you have suggested . I was hoping not to have to deal with VBScript :) -- http://mail.python.org/mailman/listinfo/python-list

f->f_locals is NULL for a method call

2005-05-27 Thread Vijay Kumar
hi, I have written a trace function in C using the Python/C API. I want to find whether the call occured is a function call or method call and if a method call, its self object. int tracer(PyObject *obj, PyObject *f, int what, PyObject *args){ PyObject *item,*SelfItem; switch(what){ case PyTrace_

Re: how to accomplish dl progress bars?

2005-05-27 Thread flamesrock
thanks! I didn't realize it was in the cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/168639 -- http://mail.python.org/mailman/listinfo/python-list

Parsing a Python dictionary inside a Python extension

2005-05-27 Thread quadric
Hi, I would like to pass a dictionary from my Python code to my Python extension, extract various values from the dictionary (from within the extension) , modify the values for the relevant keys and return the modified dictionary to Python. Can someone point me to an example of what the C code

Inserting a dictionary of lists into '__main__' of an embedded interpreter

2005-05-27 Thread quadric
Hi, I have an application that has an embedded interpreter. This application loads many DLL's and passes a PyObject * to each DLL that was gotten from the following call: PyObject * pmod = PyImport_AddModule("__main__") ; Later, in one of the many DLL's that interact with the embedded inte

Re: Determine if windows drive letter is hard drive or optical from python?

2005-05-27 Thread Do Re Mi chel La Si Do
Hi ! You can use WMI, for that. Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] XPN 0.4.6

2005-05-27 Thread Nemesis
Mentre io pensavo ad una intro simpatica "Irmen de Jong" scriveva: >> XPN (X Python Newsreader XPN) is a multi-platform newsreader with >> Unicode support. It has features like scoring/actions, X-Face and Face >> decoding, muting of quoted text, newsrc import/export, find article and >> search in

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Peter Hansen
Grant Edwards wrote: > On 2005-05-27, Peter Hansen <[EMAIL PROTECTED]> wrote: >>Unfortunately this assumes that the open() call will always succeed, >>when in fact it is likely to fail sometimes when another file has >>already opened the file but not yet completed writing to it, AFAIK. > > Not i

Re: cpu usage limit

2005-05-27 Thread Paul Rubin
"mmf" <[EMAIL PROTECTED]> writes: > How can I make sure that a Python process does not use more that 30% of > the CPU at any time. I only want that the process never uses more, but > I don't want the process being killed when it reaches the limit (like > it can be done with resource module). > > C

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Peter Hansen
Paul Rubin wrote: > http://www.sqlite.org/faq.html#q7 [snip] > Multiple processes can have the same database open at the same > time. Multiple processes can be doing a SELECT at the same > time. But only one process can be making changes to the database > at once. > > But multiple

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Paul Rubin
Peter Hansen <[EMAIL PROTECTED]> writes: > And PySQLite conveniently wraps the relevant calls with retries when > the database is "locked" by the writing process, making it roughly a > no-brainer to use SQLite databases as nice simple log files where > you're trying to write from multiple CGI proce

Re: cpu usage limit

2005-05-27 Thread Peter Hansen
rbt wrote: > [EMAIL PROTECTED] wrote: >> finished = False >> while not finished: > > Why don't you just write 'while True'??? 'while not false' is like > saying 'I am not unemployed by Microsoft' instead of saying 'I am > employed by Microsoft'. It's confusing, complex and unnecessary. Lawyers

Re: [pysqlite] Equivalent for SHOW TABLES?

2005-05-27 Thread madsurfer2000
F. GEIGER wrote: > > It would be nice somehow to be able to ask the database what tables it > contains. Is anyone doing this that way? How do you do that? > Information can be found in "Information_Schema_TABLES" See: http://www.sqlite.org/cvstrac/wiki?p=InformationSchema -- http://mail.python.o

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Paul Rubin
Jp Calderone <[EMAIL PROTECTED]> writes: > >Oh, ok. But what kind of locks does it use? > > It doesn't really matter, does it? Huh? Sure, if there's some simple way to accomplish the locking, the OP's act can do the same thing without SQlite's complexity. > I'm sure the locking mechanisms it u

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Christopher Weimann
On 05/27/2005-06:02PM, Peter Hansen wrote: > > Hmm... just tried it: you're right! On the other hand, the results were > unacceptable: each process has a separate file pointer, so it appears > whichever one writes first will have its output overwritten by the > second process. Did you open th

Re: [pysqlite] Equivalent for SHOW TABLES?

2005-05-27 Thread Peter Hansen
F. GEIGER wrote: > For now, the names of the tables, the app knows of, are added into an > internal list, when the app is started. Then, when queries fail, the app > knoes that it has to create them. > > It would be nice somehow to be able to ask the database what tables it > contains. Is anyone d

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Jp Calderone
On 27 May 2005 15:22:17 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: >Jp Calderone <[EMAIL PROTECTED]> writes: >> >Oh, ok. But what kind of locks does it use? >> >> It doesn't really matter, does it? > >Huh? Sure, if there's some simple way to accomplish the locking, the >OP's act c

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Peter Hansen
Peter Hansen wrote: > Grant Edwards wrote: >> Not in my experience. At least under Unix, it's perfectly OK >> to open a file while somebody else is writing to it. Perhaps >> Windows can't deal with that situation? > > Hmm... just tried it: you're right! Umm... the part you were right about wa

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Peter Hansen
Paul Rubin wrote: > Peter Hansen <[EMAIL PROTECTED]> writes: > >>And PySQLite conveniently wraps the relevant calls with retries when >>the database is "locked" by the writing process, making it roughly a >>no-brainer to use SQLite databases as nice simple log files where >>you're trying to write

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Peter Hansen
Christopher Weimann wrote: > On 05/27/2005-06:02PM, Peter Hansen wrote: > >>Hmm... just tried it: you're right! On the other hand, the results were >>unacceptable: each process has a separate file pointer, so it appears >>whichever one writes first will have its output overwritten by the >>sec

Re: [ANN] XPN 0.4.6

2005-05-27 Thread Irmen de Jong
Nemesis wrote: > XPN (X Python Newsreader XPN) is a multi-platform newsreader with > Unicode support. It has features like scoring/actions, X-Face and Face > decoding, muting of quoted text, newsrc import/export, find article and > search in the body, spoiler char/rot13, random taglines, and > conf

Re: Python/Excel AddIn (was:Re: Does Python have a Template::Extract equivalent from Perl's CPAN)

2005-05-27 Thread [EMAIL PROTECTED]
CL, after you install py_win32 on windows you should look for a module called "excel*.py" under your ${PYTHONHOME} directory. They have a very basic COM Server Excel AddIn as an example. -- http://mail.python.org/mailman/listinfo/python-list

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Jp Calderone
On 27 May 2005 15:10:16 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: >Peter Hansen <[EMAIL PROTECTED]> writes: >> And PySQLite conveniently wraps the relevant calls with retries when >> the database is "locked" by the writing process, making it roughly a >> no-brainer to use SQLite da

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Paul Rubin
Peter Hansen <[EMAIL PROTECTED]> writes: > I think the FAQ can answer that better than I can, since I'm not sure > whether you're asking about any low-level (OS) locks it might use or > higher-level (e.g. database-level locking) that it might use. In > summary, however, at the database level it pr

Re: write to the same file from multiple processes at the same time?

2005-05-27 Thread Andy Leszczynski
gabor wrote: > the problem is: > what happens if 2 users invoke the cgi at the same time? Would BerkleyDB support that? -- http://mail.python.org/mailman/listinfo/python-list

Re: Case Sensitive, Multiline Comments

2005-05-27 Thread Leif K-Brooks
John Roth wrote: > "Elliot Temple" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> One other interesting thing about case sensitivity I don't think >> anyone has mentioned: in Python keywords are all lowercase already >> (the way I want to type them). In some other languages,

just a test .sorry

2005-05-27 Thread Çϳª·Î
sorry -- http://mail.python.org/mailman/listinfo/python-list

unbuffering std streams in code

2005-05-27 Thread John Reese
You know how you can specify that stderr, stdin, stdout should be unbuffered by running python with the -u switch? Is there any way I can have the same affect in code by doing something to the sys.std* variables? -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a Python dictionary inside a Python extension

2005-05-27 Thread elbertlev
1. Why not to simplfy the problem. You can extract values from the dictionari in python (this is fast). Put them in a list (fast). Pass the list to the extension, handle it and return to python. etc. 2. Use Pyrex. -- http://mail.python.org/mailman/listinfo/python-list

Re: cpu usage limit

2005-05-27 Thread elbertlev
I understand, that what I suggest does not solve the problem you want, but.. Why do you want to restrict CPU usage to 30%? In Windows I run CPU intesive therads on IDLE priority, while interfacand/or communication threads run on normal. This gives me best of two worlds: 1. I use 100% CPU (good) an

Software licenses and releasing Python programs for review

2005-05-27 Thread poisondart
Hi, I'm not sure if this is the right group to post this. If not, then I would appreciate if somebody could point me to the correct group. This is my first time releasing software to the public and I'm wanting to release a Python program I wrote for review (and critique) and testing on other plat

Re: Get number of lines in file

2005-05-27 Thread Steven Bethard
Elliot Temple wrote: > > On May 27, 2005, at 12:17 PM, [EMAIL PROTECTED] wrote: > >> I have read in a file and need to get the number of lines. >> >> cpn_file = open('Central Part number list.txt') >> cpn_version = cpn_file.read().split('\n') >> >> I want to know the number of elements in

Re: Software licenses and releasing Python programs for review

2005-05-27 Thread Terry Reedy
"poisondart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > testing on other platforms, but also I would like to explore the > different software licenses that are available (there seems to be There is an Open Software Foundation (or something close) with a site listing and linki

the problem wtih cgi

2005-05-27 Thread chris patton
Hi everyone. Has anyone seen that problem with running a python cgi script in a server? It takes you to myspace.com/redmartian or something. Anyway, does anyone know when this problem will be fixed? -- http://mail.python.org/mailman/listinfo/python-list

Re: the problem wtih cgi

2005-05-27 Thread Graham Fawcett
chris patton wrote: > Hi everyone. > > Has anyone seen that problem with running a python cgi script in a > server? > It takes you to myspace.com/redmartian or something. Anyway, does > anyone know when this problem will be fixed? It could be solved much sooner if you follow these steps: (1) Care

Re: Intellisense and the psychology of typing

2005-05-27 Thread James D Carroll
<[EMAIL PROTECTED]> wrote> > 1) Intellisense is really just another crutch that does more harm than > good? There were a few hardcore defenders of this position but not > many. I'm primarily a VB programmer, but I also do Java and web stuff as well. Whenever I look at a new IDE the FIRST thing I lo

Re: regexp for sequence of quoted strings

2005-05-27 Thread Paul McGuire
George - Thanks for your enthusiastic endorsement! Here are some quibbles about your pyparsing grammar (but really, not bad for a first timer): 1. The Word class is used to define "words" or collective groups of characters, by specifying what sets of characters are valid as leading and/or body ch

Questions about wxPython...

2005-05-27 Thread Helmutt
Hi all! I'm trying to learn myself wxPython, and I got some questions: Whats the name of the event that occur when I press the exit/cross-button on the frame? How do I connect a function with that event? How do I start a new process of the same program I'm running? I do not want to create a new fr

Re: Software licenses and releasing Python programs for review

2005-05-27 Thread James William Pye
On Fri, 27 May 2005 18:50:14 -0700, poisondart wrote: > - being able to distribute it freely, anybody can modify it > - nobody is allowed to make profit from my code (other than myself) Terry mentioned OS.org, so I will not repeat that. (opensource.org) Also, check out http://creativecommons.org.

Re: search/replace in Python

2005-05-27 Thread Oliver Andrich
Hi, 2005/5/28, Vamsee Krishna Gomatam <[EMAIL PROTECTED]>: > Hello, > I'm having some problems understanding Regexps in Python. I want > to replace "PHRASE" with > "http://www.google.com/search?q=PHRASE>PHRASE" in a block of > text. How can I achieve this in Python? Sorry for the naive que

<    1   2