Re: Fatal Python error: Py_EndInterpreter: thread still has a frame

2006-02-04 Thread [EMAIL PROTECTED]
Thomas Korimort wrote: > Hi! > > Does anyone know the precise circumstances when the error > > "Fatal Python error: Py_EndInterpreter: thread still has a frame" > > does occur. I checked the source code of pythonrun.c, which tells me > that this error message is thrown in Py_EndInterpreter, when >

Re: Embedding Python into C/C++ applications

2006-02-04 Thread Roman Yakovenko
On 2/3/06, John Dean <[EMAIL PROTECTED]> wrote: > Hi > > Could somebody, please tell me where I can find information about embedding > Python into a C/C++ application. The example in the docs is rather simple. I > am looking for something a bit more complex and longer For my opinion: Boost.Python

Does Python support a peek like method for its file objects?

2006-02-04 Thread Avi Kak
Hello: Does Python support a peek like method for its file objects? I'd like to be able to look at the next byte in a disk file before deciding whether I should read it with, say, the read() method. Is it possible to do so in Python? Your answer would be much appreciated. Thanks.

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Gregory Piñero
Ok, I finally got it working! See below On 2/4/06, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > > class Node: > > def __init__(self): > > self.arg0=0 > > self.arg1=0 > > self.arg2=0 > > self.arg3=0 > >

Re: Generators vs. Functions?

2006-02-04 Thread Neil Schemenauer
Peter Hansen <[EMAIL PROTECTED]> wrote: > More precisely, the state of the function is *saved* when a yield > occurs, so you certainly don't *recreate* it from scratch, but merely > restore the state, and this should definitely be faster than creating it > from scratch in the first place. Right

Re: fairly large webapp: from Java to Python. experiences?

2006-02-04 Thread John M. Gabriele
Shalabh Chaturvedi wrote: > [EMAIL PROTECTED] wrote: > > A class-to-class and method-to-method rewrite will give some but likely > not the full benefit of moving to Python. A redesign might be necessary > - making it more 'Pythonic' in the process. In my experience, many cruft > classes that ex

Re: Python vs C for a mail server

2006-02-04 Thread John J. Lee
"Randall Parker" <[EMAIL PROTECTED]> writes: [...] > The code I'm writing in Python is a test executive to test embedded C > code. Then tests get written in Python that the test executive > processes. No, I'm not going to write yet another layer of tests in > order to compensate for shortcomings in

Re: Thread imbalance

2006-02-04 Thread Peter Hansen
Ivan Voras wrote: > Tuvas wrote: >>waits for a lul in the computing process. How can I ensure that this >>does not happen? This thread uses little processing power, so it could >>be set to a high priority, if there is a way to do this. Thanks! > > Python is bad for concurrently executing/computing

Re: Generators vs. Functions?

2006-02-04 Thread Peter Hansen
Joseph Garvin wrote: > Wolfgang Keller wrote: >>If this is actually also true in the general case, and not due to eventual >>non-representativeness of the test mentioned above, is it simply due to a >>less-than-optimum implementation of generators in the current Pyython >>interpreter and thus li

Re: Python vs C for a mail server

2006-02-04 Thread John J. Lee
"Randall Parker" <[EMAIL PROTECTED]> writes: [...] > Also, a lot of C++'s flaws flow from the fact that it is old and grew > in lots of increments. That was a deliberate decision on the part of C++'s designers!-) I guess the same is true of Python in some respects: it's still incrementally changi

Re: numeric expression from string?

2006-02-04 Thread Giovanni Bajo
Brian Blais wrote: > I have a string input from the user, and want to parse it to a > number, and would like to know how to do it. I would like to be able > to accept arithmetic operations, like: > > '5+5' > '(4+3)*2' > '5e3/10**3' > > I thought of using eval, which will work, but could lead to b

Re: Thread imbalance

2006-02-04 Thread Ivan Voras
Tuvas wrote: > waits for a lul in the computing process. How can I ensure that this > does not happen? This thread uses little processing power, so it could > be set to a high priority, if there is a way to do this. Thanks! Python is bad for concurrently executing/computing threads, but it shoul

Re: would it be feasable to write python DJing software

2006-02-04 Thread Ivan Voras
Ivan Voras wrote: > Because "bar and aba happen to be parts of extension library" :) To end this disussion: I meant "doing it in C" as a colloquial expression, not a technical one. The expression holds true for every case where a function/class/module/etc is implemented in a lower-level langua

Re: would it be feasable to write python DJing software

2006-02-04 Thread Ivan Voras
Fredrik Lundh wrote: > > uhuh? so why did you just argue that > > if foo.bar(): > bar.aba() > > means "doing it in C" if bar and aba happens to be parts of an extension > library ? Because "bar and aba happen to be parts of extension library" :) -- http://mail.python.org/mailman/

python port for iPod

2006-02-04 Thread jack
Hi, Since May 2005 there is a port of python (v2.4.1) for Apple iPod. Porting was an 'easy' job, the only consideration was how you can write with a iPod, ipodlinux [1] people did an interface called iPodRead that allows you type into iPod scrolling left or right on the wheel. (This affects

Re: fairly large webapp: from Java to Python. experiences?

2006-02-04 Thread Shalabh Chaturvedi
[EMAIL PROTECTED] wrote: > I've got a fairly substantial webapp written in Java (plus Tomcat, > Hibernate, Struts, JSP, MySQL) that is a bit of a bear to work with. I > didn't write it. Much of it is only very sparsely documented (if at > all). No design docs anywhere. It's a large webapp with many

Re: Generators vs. Functions?

2006-02-04 Thread Max
Joseph Garvin wrote: > > I am not a CPython or PyPy hacker, but I would guess that it will always > be slower as a matter of principal. When resuming a generator you have > to resetup the state the function was in when it was last called, which > I think should always be more costly than callin

how to run BeautifulSoup in Jython

2006-02-04 Thread ye juan
Hi, Anyone tries to use BeautifulSoup ( http://www.crummy.com/software/BeautifulSoup/ ) in Jython? I can not run that ,the error that Jython gives me is: unpack sequence too long. Sincerely, Erica __ 赶快注册雅虎超大容量免费邮箱? http://cn.mail.yahoo.com --

Re: A problem with some OO code.

2006-02-04 Thread Erik Max Francis
TPJ wrote: > I understand your POV and I really appereciate your reply, but I doubt > that I could simplify my code to make it small *enough* to fit in one > post and not look too long. The pont of the exercise of taking non-working code and trying to cut away parts that aren't part of the probl

Re: Webmail with Python

2006-02-04 Thread Larry Bates
Thomas Guettler wrote: > Hi, > > Is there an application like Squirrelmail[1] written in python? > > I want to access IMAP folder with a web-browser. > > Google shows me some dead projects. Most webmail applications > seem to be written in PHP. Is there a useable webmailer written > in python? >

Re: Making Popen items terminate when program ends.

2006-02-04 Thread Ernesto
Peter Hansen wrote: > Please see this page: http://docs.python.org/ref/strings.html and read > about escape sequences in strings, and about raw strings. Thanks Peter. Forgot about that one. In a way, I wish it *would* have given me trouble, so I could have found it early rather than later. --

Re: re.search slashes

2006-02-04 Thread Scott David Daniels
pyluke wrote: > Scott David Daniels wrote: >> pyluke wrote: >>> I... want to find lines with ... "\[" but not instances of "\\[" >> >> If you are parsing with regular expressions, you are running a marathon. >> If you are doing regular expressions without raw strings, you are running >> a marathon

Re: Generators vs. Functions?

2006-02-04 Thread Joseph Garvin
Wolfgang Keller wrote: >If this is actually also true in the general case, and not due to eventual >non-representativeness of the test mentioned above, is it simply due to a >less-than-optimum implementation of generators in the current Pyython >interpreter and thus likely to change in the futu

Re: fairly large webapp: from Java to Python. experiences?

2006-02-04 Thread Giovanni Bajo
John M. Gabriele wrote: >> But once it is >> there, Python is a good choice for web apps. Java is slow > > Slow? They're both dynamic languages, but Java is statically > typed (with less work to do at runtime). For long-running processes, > I'd guess that Java bytecode executes faster than Python

Webmail with Python

2006-02-04 Thread Thomas Guettler
Hi, Is there an application like Squirrelmail[1] written in python? I want to access IMAP folder with a web-browser. Google shows me some dead projects. Most webmail applications seem to be written in PHP. Is there a useable webmailer written in python? Thomas -- Thomas Guettler, http://www

Re: re.search slashes

2006-02-04 Thread pyluke
> 2. Read the module's documentation. Several time. In your case read the > "negative lookbehind assertion" part "(? you understand how it may be of use to you. OK. lookbehind would be more useful/suitable here... -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Scott David Daniels
Gregory Piñero wrote: > I want to walk down each tree and get a random subtree at a random > depth. Can you quantify that randomness? Should it be uniform at each level? Thinking about this may be fruitful. I don't yet know whether you need to see all leaves before you know which subtree

Generators vs. Functions?

2006-02-04 Thread Wolfgang Keller
Hello, in <[EMAIL PROTECTED]>, Magnus Lycka <[EMAIL PROTECTED]> posts the result of a short test that seems to indicate that resuming a generator takes more time than calling a function. If this is actually also true in the general case, and not due to eventual non-representativeness of the te

Re: re.search slashes

2006-02-04 Thread pyluke
> To add to what scott said, two advices: > 1. Use Kodos, it's a RE debugger and an extremely fine tool to generate > your regular expressions. Ok, just found this. Will be helpful. > 2. Read the module's documentation. Several time. In your case read the > "negative lookbehind assertion" par

Re: re.search slashes

2006-02-04 Thread pyluke
Scott David Daniels wrote: > pyluke wrote: >> I'm parsing LaTeX document and want to find lines with equations >> blocked by "\[" and "\]", but not other instances of "\[" like "a & b >> & c \\[5pt]" >> so, in short, I was to match "\[" but not "\\]" I've tried: >> check_eq = re.compile('(?

Re: re.search slashes

2006-02-04 Thread Xavier Morel
Scott David Daniels wrote: > pyluke wrote: >> I'm parsing LaTeX document and want to find lines with equations blocked >> by "\[" and "\]", but not other instances of "\[" like "a & b & c \\[5pt]" >> so, in short, I was to match "\[" but not "\\]" I've tried: >> check_eq = re.compile('(?!\%\

Re: re.search slashes

2006-02-04 Thread Scott David Daniels
pyluke wrote: > I'm parsing LaTeX document and want to find lines with equations blocked > by "\[" and "\]", but not other instances of "\[" like "a & b & c \\[5pt]" > so, in short, I was to match "\[" but not "\\]" I've tried: > check_eq = re.compile('(?!\%\s*)\[') > check_eq.search(li

Re: OS.MKDIR( ) Overwriting previous folder created...

2006-02-04 Thread Florian Diesch
Ernesto <[EMAIL PROTECTED]> wrote: > NEVERMIND ! Here is the solution... > > # > if (os.path.isdir("C:\\MyNewFolder") == 0): > os.mkdir("C:\\MyNewFolder") > # - M

Re: A problem with some OO code.

2006-02-04 Thread TPJ
At first I'd like to thank you for such a long answer. > (...) > You need to simplify the code as much as possible, cutting away everything > you can, to the SMALLEST amount of code that still experiences the problem. I understand your POV and I really appereciate your reply, but I doubt that I c

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Gregory Piñero
Thanks for the advice guys. See below. On 2/4/06, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > > > class Node: > > def __init__(self): > > self.arg0=0 > > self.arg1=0 > > self.arg2=0 > > self.arg3=0 >

Re: Another try at Python's selfishness

2006-02-04 Thread Nick Craig-Wood
Terry Hancock <[EMAIL PROTECTED]> wrote: > On Thu, 02 Feb 2006 19:27:55 -0600 > DH <[EMAIL PROTECTED]> wrote: > > But I think most people who don't like the extraneous > > 'self' in python just consider it a minor inconvenience > > and don't even notice it after using python for a while. > >

Extract contents of html cells

2006-02-04 Thread Robot
Dear all, I need to create a script which will extract the contents of 2 cells of an html that contains a specified number of cells.Then I need to put that contents in another cells of my own html page.How can i do that?Any samples, tutorials, advice? -- http://mail.python.org/mailman/listinfo/py

Re: Extract contents of html cells

2006-02-04 Thread Jason Earl
Robot <[EMAIL PROTECTED]> writes: > Dear all, > I need to create a script which will extract the contents of 2 cells > of an html that contains a specified number of cells.Then I need to > put that contents in another cells of my own html page.How can i do > that?Any samples, tutorials, advice?

Re: Extract contents of html cells

2006-02-04 Thread Larry Bates
Robot wrote: > Dear all, > I need to create a script which will extract the contents of 2 cells of > an html that contains a specified number of cells.Then I need to put > that contents in another cells of my own html page.How can i do that?Any > samples, tutorials, advice? > You should take a lo

Re: Another try at Python's selfishness

2006-02-04 Thread Donn Cave
Quoth [EMAIL PROTECTED]: ... | The first point is: Python has global functions, as well as methods. If | f(a) should look up f inside a first, that would shadow any global or | local f. That's bad, because python is dynamically typed, and you | sometimes down' know what "a" is. Things like "open(fi

Re: Extract contents of html cells

2006-02-04 Thread Rene Pijlman
Robot: >I need to create a script which will extract the contents of 2 cells of >an html that contains a specified number of cells.Then I need to put >that contents in another cells of my own html page.How can i do that? http://www.python.org/doc/lib/module-htmllib.html -- René Pijlman -- http:

re.search slashes

2006-02-04 Thread pyluke
I'm parsing LaTeX document and want to find lines with equations blocked by "\[" and "\]", but not other instances of "\[" like "a & b & c \\[5pt]" so, in short, I was to match "\[" but not "\\]" to add to this, I also don't want lines that start with comments. I've tried: check_eq = re.compil

Re: OO conventions

2006-02-04 Thread Alex Martelli
Blair P. Houghton <[EMAIL PROTECTED]> wrote: ... > > It is (search for 'staticmethod' and 'classmethod'). But there's not > > much use for 'static methods' in Python - we usually just use plain > > functions ('classmethods' are another beast - much more useful than > > staticmethods) > > Does i

Re: OO conventions

2006-02-04 Thread Alex Martelli
Daniel Nogradi <[EMAIL PROTECTED]> wrote: ... > So after all, what is a 'factory' or 'factory function'? A brief explanation in Python terms is at http://www.aleax.it/ep03_pydp.pdf -- "pages" (slides) 37-44 (the rest of the presentation is about an even more fundamental design pattern, "templat

Re: numeric expression from string?

2006-02-04 Thread Tim Chase
> I have a string input from the user, and want to parse it > to a number, and would like to know how to do it. I > would like to be able to accept arithmetic operations, > like: > > '5+5' > '(4+3)*2' > '5e3/10**3' > > I thought of using eval, which will work, but could lead > to bad security pr

Re: A problem with some OO code.

2006-02-04 Thread TPJ
Thank you VERY much! These other errors are not so serious. I think I'll fix them soon. The most important thing is that now I'm ready to work on that code again. Life is beautiful again! Damn, I knew it is some very stupid mistake. I must learn how to use that pylint, instead of asking people on

Re: OO conventions

2006-02-04 Thread Steve Holden
Daniel Nogradi wrote: [...] > So after all, what is a 'factory' or 'factory function'? The name is intended to be indicative: it's a function that makes things - usually instances of some class. As has already been pointed out. Image is a module from PIL, so Image.open() is a function in that m

Re: numeric expression from string?

2006-02-04 Thread Claudio Grondi
Brian Blais wrote: > Hello, > > I have a string input from the user, and want to parse it to a number, > and would like to know how to do it. I would like to be able to accept > arithmetic operations, like: > > '5+5' > '(4+3)*2' > '5e3/10**3' > > I thought of using eval, which will work, but

Re: numeric expression from string?

2006-02-04 Thread Steven D'Aprano
On Sat, 04 Feb 2006 06:48:11 -0500, Brian Blais wrote: > Hello, > > I have a string input from the user, and want to parse it to a number, and > would like > to know how to do it. I would like to be able to accept arithmetic > operations, like: > > '5+5' > '(4+3)*2' > '5e3/10**3' > > I thou

Re: numeric expression from string?

2006-02-04 Thread Diez B. Roggisch
Brian Blais schrieb: > Hello, > > I have a string input from the user, and want to parse it to a number, > and would like to know how to do it. I would like to be able to accept > arithmetic operations, like: > > '5+5' > '(4+3)*2' > '5e3/10**3' > > I thought of using eval, which will work, bu

Re: Another try at Python's selfishness

2006-02-04 Thread n . estner
Donn Cave wrote: > Quoth [EMAIL PROTECTED]: > | > Still see no problem. Of course, it goes without saying that > | > Python 2.4 doesn't work this way, but given that it's theoretically > | > possible for f(a) to be resolved similarly to a.f, then I really > | > do not see what you're seeing here.

Re: A problem with some OO code.

2006-02-04 Thread Steven D'Aprano
On Sat, 04 Feb 2006 04:21:50 -0800, TPJ wrote: > Help me please, because I really don't get it. I think it's some stupid > mistake I make, but I just can't find it. I have been thinking about it > for three days so far and I still haven't found any solution. > > My code can be downloaded from her

Re: A problem with some OO code.

2006-02-04 Thread Diez B. Roggisch
> AttributeError: 'Obj' object has no attribute > '_Object__ls_demanded_links' > -- > > Perhaps I'll explain what's going on there. First, the objects' manager > is created, and then also some objects are created. After doing that, > the object calle

Re: Making Popen items terminate when program ends.

2006-02-04 Thread Peter Hansen
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Peter Hansen <[EMAIL PROTECTED]> wrote: > >>You should >>either prefix your string with an "r" (just before the opening quotation >>mark) or escape the backslashes (as in use "C:\\Folder..." instead of >>just "C:\Folder"). > > Of the two al

Re: Graphical introspection utilities?

2006-02-04 Thread Ravi Teja
Oops. http://www.activestate.com/_images/screenshots/ss_Komodo_rails_large.gif is the debugger screenshot for Ruby (Komodo supports more than one language). Python's debugger in Komodo looks exactly the same. -- http://mail.python.org/mailman/listinfo/python-list

Re: Another try at Python's selfishness

2006-02-04 Thread Jens Theisen
n.estner wrote: > Yes, I 100% agree to that point! > But the point is, the current situation is not newbie-friendly (I can > tell, I am a newbie): I declare a method with 3 parameters but when I > call it I only pass 2 parameters. That's confusing. If I declare a > member variable, I write: "self.

Re: Graphical introspection utilities?

2006-02-04 Thread Ravi Teja
> as it would be so obviously a good thing to have a graphical (or maybe > curses-base) browser through the dynamic state of a Python program, it's > probably there. > > Can someone point me to something? If you mean graphical debuggers, most Python specific IDEs have them. Few examples .. Python

Re: OO conventions

2006-02-04 Thread Daniel Nogradi
> > Actually, this way of creating a class instance is good OO practice in > > many places: The Image.open() method acts as a factory-function for > > creating Image objects. > > You don't know, until you inspect the return value, if the created > > object is actually an instance of class Image or

numeric expression from string?

2006-02-04 Thread Brian Blais
Hello, I have a string input from the user, and want to parse it to a number, and would like to know how to do it. I would like to be able to accept arithmetic operations, like: '5+5' '(4+3)*2' '5e3/10**3' I thought of using eval, which will work, but could lead to bad security problems (n

A problem with some OO code.

2006-02-04 Thread TPJ
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2.

Re: Python on Windows

2006-02-04 Thread Xavier Morel
Grant Edwards wrote: > Definitely. Nobody does single .exe file windows programs > anymore. A single-file installer is almost as easy. > uTorrent, Process Explorer or Media Player Classic are single .exe windows programs. Granted, most of them are under-150kb-works-of-arts, but MPC isn't (well

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Steven D'Aprano
On Sat, 04 Feb 2006 02:18:27 -0500, Gregory Piñero wrote: > Hi, > > Would anyone be able to tell me why my function below is getting stuck > in infinite recusion? > Maybe I'm just tired and missing something obvious? Your code is quite confusing, especially since there is very little documentati

Re: fairly large webapp: from Java to Python. experiences?

2006-02-04 Thread Scott David Daniels
John M. Gabriele wrote: > [EMAIL PROTECTED] wrote: >> But once it is >> there, Python is a good choice for web apps. Java is slow > > Slow? They're both dynamic languages, but Java is statically > typed (with less work to do at runtime). For long-running processes, > I'd guess that Java bytecode e

Re: Starting terminal applications from within python

2006-02-04 Thread Jorgen Grahn
On 2 Feb 2006 09:41:20 -0800, sleepylight <[EMAIL PROTECTED]> wrote: > Ah! I see now. That makes prefect sense. I guess I was thinking that > python was simply going to pass a whole command string to the program > rather than give each argument as individual strings. Seeing this > makes the doc

Graphical introspection utilities?

2006-02-04 Thread Jens Theisen
Hello, as it would be so obviously a good thing to have a graphical (or maybe curses-base) browser through the dynamic state of a Python program, it's probably there. Can someone point me to something? Cheers, Jens -- http://mail.python.org/mailman/listinfo/python-list

Re: python's library support

2006-02-04 Thread bearophileHUGS
Robert Kern>And several others if you google a bit. Yes: http://sourceforge.net/projects/pynetwork/ Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression query

2006-02-04 Thread Giovanni Bajo
Martin Biddiscombe wrote: > "parameter=12ab" > "parameter=12ab foo bar" > "parameter='12ab'" > "parameter='12ab' biz boz" > "parameter="12ab"" > "parameter="12ab" junk" >>> import shlex >>> def extract(s): ... s = s.split("=")[1] ... s = shlex.split(s)[0] ... return s ... >>> extract(

Re: Recursive function going infinite and I can't see why.

2006-02-04 Thread Terry Reedy
>Would anyone be able to tell me why my function below is getting stuck >in infinite recusion? >def replace_within_node(node,oldnode,newnode): >if node is oldnode: >return newnode Without looking further, the most likely reason is that the base case is never true: ie, node is never o

Re: Another try at Python's selfishness

2006-02-04 Thread Terry Reedy
"Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm not sure I follow. Surely you're not suggesting that this doesn't > work: > >>>> class X: >... def foo(self): >... print 'X.foo', self >... >>>> class A(X): >... pass