Re: Python in C

2008-12-29 Thread akineko
Although this is not what you are asking but I'm wondering why you need to read CPython implementation. I have been using Python for 7 or 8 years but I've never encountered any situations where I need to read CPython implementation. I needed to read library implementations and installer codes, thou

Re: Python 3.0 Curses Unicode

2008-12-29 Thread Damian Johnson
It seems as if the curses module in Python 3.0 isn't respecting the system's preferred encoding (utf-8) which was set via: locale.setlocale(locale.LC_ALL, '') The purpose of this was described at the top of ' http://docs.python.org/dev/3.0/library/curses.html#module-curses'. The getlocale function

How to debug embeding Python?

2008-12-29 Thread Hongtian
Hi Friends, My application is written in C/C++ and Python is embed to extend some functions (several .py files are invoked). But I am confused how to debug these embed Python? Can I use 'print-debuging'? and where can I capture the output string? Or Python can support 'break' debug for such scena

Re: Get a list of functions in a file

2008-12-29 Thread member Basu
Thanks for all your replies, but the thing is I want to get the list of functions in that file itself, not by importing it as a module. I've decided to go with a class-based approach due to a number of other reasons, but I'm still interested in a way to get function name in that file itself. Thanks

Re: How do I DRY the following code?

2008-12-29 Thread Patrick Mullen
On Mon, Dec 29, 2008 at 6:13 PM, R. Bernstein wrote: > How do I DRY the following code? > > class C(): > > def f1(self, arg1, arg2=None, globals=None, locals=None): > ... unique stuff #1 ... > ... some common stuff #1 ... > ret = eval(args, globals, locals) > ... more stuff #2

Re: Of console I/O, characters, strings & dogs

2008-12-29 Thread John Machin
On Dec 30, 11:53 am, David Lemper wrote: > I am trying getch() from msvcrt. Unfortunately the msvcrt docs have not been 2to3ified: """ msvcrt.getch() Read a keypress and return the resulting character. Nothing is echoed to the console. This call will block if a keypress is not already available, b

Re: New Python 3.0 string formatting - really necessary?

2008-12-29 Thread Luis M . González
On Dec 29, 9:44 pm, Steven D'Aprano wrote: > How do you lose backward compatibility by *adding* new functionality? The > old functionality will continue to work as normal. > > -- > Steven AFAIK it still works the old way, but it will be deprecated soon. -- http://mail.python.org/mailman/listinfo/

Re: Python in C

2008-12-29 Thread Gabriel Genellina
En Tue, 30 Dec 2008 00:32:45 -0200, escribió: BTW, as a person who hasn't really written a stitch of C++ in about 10 years I personally find the CPython implementation to be one of the most well-organized large pieces of code I have ever encountered. It's much easier to read (to me) than any

Re: Python module import loop issue

2008-12-29 Thread Kottiyath
On Dec 30, 8:24 am, "Gabriel Genellina" wrote: > En Mon, 29 Dec 2008 19:47:51 -0200, Carl Banks   > escribió: > > > On Dec 29, 10:51 am, Kottiyath wrote: > >> Module Factory: > >> A1Factory: {'B1Tag':1.1.B1, 'C1Tag':1.2.C1, 'D1Tag':1.3.D1'} > >> A2Factory: {'B2Tag':2.1.B2, 'C2Tag':2.2.C2, 'D2Tag

Re: print a vs print '%s' % a vs print '%f' a

2008-12-29 Thread David Cournapeau
On Tue, Dec 30, 2008 at 12:23 PM, James Mills wrote: > On Tue, Dec 30, 2008 at 1:19 PM, David Cournapeau wrote: > (... snip ...) > >> print '%f' % a # -> print '1.#INF' > > Would this not be controlled by: > 1. float(a) or a.__float__() > 2. tp_print Bah, I made a mistake in my example: complex(

Re: Python module import loop issue

2008-12-29 Thread Carl Banks
Gabriel Genellina wrote: > En Mon, 29 Dec 2008 19:47:51 -0200, Carl Banks > escribi�: > > On Dec 29, 10:51�am, Kottiyath wrote: > > >> Module Factory: > >> A1Factory: {'B1Tag':1.1.B1, 'C1Tag':1.2.C1, 'D1Tag':1.3.D1'} > >> A2Factory: {'B2Tag':2.1.B2, 'C2Tag':2.2.C2, 'D2Tag':2.3.D2'} > >> > >> But,

Re: print a vs print '%s' % a vs print '%f' a

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 1:19 PM, David Cournapeau wrote: (... snip ...) > print '%f' % a # -> print '1.#INF' Would this not be controlled by: 1. float(a) or a.__float__() 2. tp_print cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: Python module import loop issue

2008-12-29 Thread Gabriel Genellina
En Mon, 29 Dec 2008 19:47:51 -0200, Carl Banks escribió: On Dec 29, 10:51 am, Kottiyath wrote: Module Factory: A1Factory: {'B1Tag':1.1.B1, 'C1Tag':1.2.C1, 'D1Tag':1.3.D1'} A2Factory: {'B2Tag':2.1.B2, 'C2Tag':2.2.C2, 'D2Tag':2.3.D2'} But, since Module requires objects of B1, C1 etc, it has

print a vs print '%s' % a vs print '%f' a

2008-12-29 Thread David Cournapeau
Hi, While working on some python C extensions, I got curious in how things work for printing float objects (and C-level objects which inherit from it). In python 2.6, I understand that the formatting went into surgery for more consistency across platforms. So for example, on windows, complex('inf'

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 12:52 PM, Aaron Brady wrote: > On Dec 29, 7:40 pm, "James Mills" > wrote: >> On Tue, Dec 30, 2008 at 11:34 AM, Aaron Brady wrote: >> > The OP may be interested in Erlang, which Wikipedia (end-all, be-all) >> > claims is a 'distribution oriented language'. > snip >> I'm pr

Re: multiprocessing vs thread performance

2008-12-29 Thread Aaron Brady
On Dec 29, 7:40 pm, "James Mills" wrote: > On Tue, Dec 30, 2008 at 11:34 AM, Aaron Brady wrote: > > The OP may be interested in Erlang, which Wikipedia (end-all, be-all) > > claims is a 'distribution oriented language'. snip > I'm presently looking at Virtual Synchrony and > other distributed pro

Re: Python in C

2008-12-29 Thread David Cournapeau
On Tue, Dec 30, 2008 at 10:22 AM, wrote: > I've just downloaded Python's mainstream implementation (CPython), > which is written in C. Not to my surprise, I feel like I'm looking at > unstructured spaghetti, and I'm having trouble figuring out how it all > works together. (Please bear with me; I'

Re: get method

2008-12-29 Thread Aaron Brady
On Dec 29, 8:02 pm, Steven D'Aprano wrote: > On Mon, 29 Dec 2008 17:38:36 -0800, Ross wrote: > > On Dec 29, 8:07 pm, Scott David Daniels wrote: > >> Ross wrote: > >> > ... Use get to write histogram more concisely. You should be able to > >> > eliminate the if statement. > > >> > def histogram(s)

Re: Read-Write Lock vs primitive Lock()

2008-12-29 Thread Gabriel Genellina
En Mon, 29 Dec 2008 08:17:42 -0200, k3xji escribió: On 29 Aralık, 11:52, "Gabriel Genellina" wrote: En Mon, 29 Dec 2008 05:56:10 -0200, k3xji escribió: > I  am trying to see on which situations does the Read-Write Lock > performs better on primitive Lock() itself. Below is the code I am > u

Re: Python in C

2008-12-29 Thread skip
thmpsn> 1. Can anyone explain to me what kind of program structuring thmpsn>technique (which paradigm, etc) CPython uses? How do modules thmpsn>interact together? What conventions does it use? it's quite object-oriented once you understand how things are done. Take a look, f

Re: "return" in def

2008-12-29 Thread Aaron Brady
On Dec 29, 7:00 pm, Steven D'Aprano wrote: > On Mon, 29 Dec 2008 05:31:17 -0800, Aaron Brady wrote: > > One style of coding I heard about once only permits returns at the end > > of a function.  It claims it makes it easier to see the function as a > > mathematical object. > > That's silly. You tr

How do I DRY the following code?

2008-12-29 Thread R. Bernstein
How do I DRY the following code? class C(): def f1(self, arg1, arg2=None, globals=None, locals=None): ... unique stuff #1 ... ... some common stuff #1 ... ret = eval(args, globals, locals) ... more stuff #2 ... return retval def f2(self, arg1, arg2=None, *args,

Re: get method

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 17:38:36 -0800, Ross wrote: > On Dec 29, 8:07 pm, Scott David Daniels wrote: >> Ross wrote: >> > ... Use get to write histogram more concisely. You should be able to >> > eliminate the if statement. >> >> > def histogram(s): >> >    d = dict() >> >    for c in s: >> >        

Re: Python in C

2008-12-29 Thread Paul Rubin
thmpsn@gmail.com writes: > 1. Can anyone explain to me what kind of program structuring technique > (which paradigm, etc) CPython uses? How do modules interact together? > What conventions does it use? There are a bunch of docs about this, you could read them. The program is written about the

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:43 AM, James Mills wrote: > On Tue, Dec 30, 2008 at 11:38 AM, Ross wrote: >> I realize the code isn't counting, but how am I to do this without >> using an if statement as the problem instructs? > > I just gave you a hint :) Ross: This exercise is a simple exercise de

Re: why cannot assign to function call

2008-12-29 Thread Aaron Brady
On Dec 29, 6:06 pm, Miles wrote: > On Mon, Dec 29, 2008 at 1:01 AM, scsoce wrote: > > I have a function return a reference, and want to assign to the reference, > > simply like this: > >>>def f(a) > >         return a > >    b = 0 > >   * f( b ) = 1* > > but the last line will be refused as "can'

Re: Python in C

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:32 AM, Chris Rebert wrote: > On Mon, Dec 29, 2008 at 5:22 PM, wrote: > >> 2. Have there been any suggestions in the past to rewrite Python's >> mainstream implementation in C++ (or why wasn't it done this way from >> the beginning)? > > I'm not a CPython dev (I bet on

Re: Of console I/O, characters, strings & dogs

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 18:53:45 -0600, David Lemper wrote: > I am trying getch() from msvcrt. The following module has been run with > 3 different concatination statements and none yield a satisfactory > result.Python 3.0 Your first problem is that you've run into the future of computing: str

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:38 AM, Ross wrote: > I realize the code isn't counting, but how am I to do this without > using an if statement as the problem instructs? I just gave you a hint :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:34 AM, Aaron Brady wrote: > The OP may be interested in Erlang, which Wikipedia (end-all, be-all) > claims is a 'distribution oriented language'. I would suggest to the OP that he take a look at circuits (1) an event framework with a focus on component architectures and

Re: get method

2008-12-29 Thread Ross
On Dec 29, 8:07 pm, Scott David Daniels wrote: > Ross wrote: > > ... Use get to write histogram more concisely. You should be able to > > eliminate the if statement. > > > def histogram(s): > >    d = dict() > >    for c in s: > >            d[c]= d.get(c,0) > >    return d > > > This code returns

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:32 AM, James Mills wrote: > Ross, the others have informed you that you are not > actually incrementing the count. I'll assume you've > fixed your function now :) ... I want to show you a far > simpler way to do this which takes advantage of > Python's list comprehension

Re: multiprocessing vs thread performance

2008-12-29 Thread Aaron Brady
On Dec 29, 6:05 pm, "James Mills" wrote: > On Tue, Dec 30, 2008 at 12:52 AM, mk wrote: > > Hello everyone, > > > After readinghttp://www.python.org/dev/peps/pep-0371/I was under > > impression that performance of multiprocessing package is similar to that of > > thread / threading. However, to fa

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:00 AM, Ross wrote: > I am teaching myself Python by going through Allen Downing's "Think > Python." I have come across what should be a simple exercise, but I am > not getting the correct answer. Here's the exercise: > > Given: > > def histogram(s): >d = dict() >

Re: Python in C

2008-12-29 Thread Chris Rebert
On Mon, Dec 29, 2008 at 5:22 PM, wrote: > 2. Have there been any suggestions in the past to rewrite Python's > mainstream implementation in C++ (or why wasn't it done this way from > the beginning)? I'm not a CPython dev (I bet one will pipe in), but I would speculate it's because C++ is so muc

Python in C

2008-12-29 Thread thmpsn . m . k
I've just downloaded Python's mainstream implementation (CPython), which is written in C. Not to my surprise, I feel like I'm looking at unstructured spaghetti, and I'm having trouble figuring out how it all works together. (Please bear with me; I'm just going through the usual frustration that any

Re: get method

2008-12-29 Thread Scott David Daniels
Ross wrote: ... Use get to write histogram more concisely. You should be able to eliminate the if statement. def histogram(s): d = dict() for c in s: d[c]= d.get(c,0) return d This code returns a dictionary of all the letters to any string s I give it but

Re: get method

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 17:00:31 -0800, Ross wrote: > Here's my code: > > def histogram(s): > d = dict() > for c in s: > d[c]= d.get(c,0) > return d > > This code returns a dictionary of all the letters to any string s I give > it but each corresponding value is incor

Re: "return" in def

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 05:31:17 -0800, Aaron Brady wrote: > One style of coding I heard about once only permits returns at the end > of a function. It claims it makes it easier to see the function as a > mathematical object. That's silly. You treat the function as a black box: input comes in, and

get method

2008-12-29 Thread Ross
I am teaching myself Python by going through Allen Downing's "Think Python." I have come across what should be a simple exercise, but I am not getting the correct answer. Here's the exercise: Given: def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1

Of console I/O, characters, strings & dogs

2008-12-29 Thread David
I am trying getch() from msvcrt. The following module has been run with 3 different concatination statements and none yield a satisfactory result.Python 3.0 # script12 import msvcrt shortstr1 = 'd' + 'o' + 'g' print(shortstr1) char1 = msvcrt.getch() char2 = msvcrt.getch() char3 = msvcrt.getch

Re: New Python 3.0 string formatting - really necessary?

2008-12-29 Thread Steven D'Aprano
On Mon, 29 Dec 2008 09:50:14 -0800, walterbyrd wrote: > On Dec 21, 12:28 pm, Bruno Desthuilliers > wrote: > >> > I can see where the new formatting might be helpful in some cases. >> > But, I am not sure it's worth the cost. >> >> Err... _Which_ cost exactly ? > > Loss of backward compatibility

Re: why cannot assign to function call

2008-12-29 Thread Miles
On Mon, Dec 29, 2008 at 1:01 AM, scsoce wrote: > I have a function return a reference, and want to assign to the reference, > simply like this: >>>def f(a) > return a >b = 0 > * f( b ) = 1* > but the last line will be refused as "can't assign to function call". > In my thought , the

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 12:52 AM, mk wrote: > Hello everyone, > > After reading http://www.python.org/dev/peps/pep-0371/ I was under > impression that performance of multiprocessing package is similar to that of > thread / threading. However, to familiarize myself with both packages I > wrote my o

Re: flushing of print statements ending with comma

2008-12-29 Thread Cameron Simpson
On 29Dec2008 11:11, Grebekel wrote: | I have recently noticed that print statements ending with a comma are | not immediately flushed. I will warn you that neither are the more common uncommaed print statements, except on a terminal. | [...] Example: | | print 'Take a walk, because this will ta

Re: New Python 3.0 string formatting - really necessary?

2008-12-29 Thread ajaksu
On Dec 29, 7:37 pm, Luis M. González wrote: > I still can't get used to add the parenthesis to "print", and this is > the only thing I don't like, but I'm sure there's a good reason for > this change... I should know better than to post such an awful hack: __past__.py: from sys import excepthoo

Re: SQL, lite lite lite

2008-12-29 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aaron Brady wrote: > Python. There are some options, such as 'sqllite3', but they are not > easy. 'sqllite3' statements are valid SQL expressions, which afford > the entire power of SQL, but contrary to its name, it is not that > 'lite'. Have you c

Re: Python module import loop issue

2008-12-29 Thread Carl Banks
On Dec 29, 10:51 am, Kottiyath wrote: > This might not be  pure python question. Sorry about that. I couldnt > think of any other place to post the same. > I am creating a _medium_complex_ application, and I am facing issues > with creating the proper module structure. > This is my first applicati

Re: New Python 3.0 string formatting - really necessary?

2008-12-29 Thread Luis M . González
On 19 dic, 13:01, walterbyrd wrote: > I have not worked with Python enough to really know. But, it seems to > me that more I look at python 3.0, the more I wonder if it isn't a > step backwards. > > To me, it seems that this: > > print "%s=%d" % ('this',99) > > Is much easier, and faster, to type,

Re: tkInter constraining the width only

2008-12-29 Thread Roger
On Dec 29, 3:23 pm, akineko wrote: > Hello everyone, > > I'm writing a Tkinter program and trying to constraint the window > size. > I want to set the minimum of the width and the height and the maximum > of the width, but not the height. You want to set the max height to 0. I know this is count

Re: multiprocessing vs thread performance

2008-12-29 Thread Hrvoje Niksic
Roy Smith writes: > In article , > Christian Heimes wrote: > >> You have missed an important point. A well designed application does >> neither create so many threads nor processes. The creation of a thread >> or forking of a process is an expensive operation. You should use a pool >> of thread

tkInter constraining the width only

2008-12-29 Thread akineko
Hello everyone, I'm writing a Tkinter program and trying to constraint the window size. I want to set the minimum of the width and the height and the maximum of the width, but not the height. I can use minsize(width=min_width, height=min_height) from Wm method to limit the minimum sizes. Similarly

Symposium “Image Processing and Analysis” within the ICCES'09 Thailand – Last Announce & Call for Papers

2008-12-29 Thread tava...@fe.up.pt
(Our apologies for cross-posting. We appreciate if you kindly distribute this information by your co- workers and colleagues.) *** Symposium “Image Processing and Analysis” Int. Conf. on Computatio

Re: math module for Decimals

2008-12-29 Thread Tino Wildenhain
jerry.carl...@gmail.com wrote: ... It's really just the goniometric functions that I am missing most at the moment, so maybe I can figure it out with help of what you said plus the already existing imperfect modules. Meantime maybe this discussion will caught Guido's eye... ;-) And btw I do expec

Re: why cannot assign to function call

2008-12-29 Thread Terry Reedy
John Machin wrote: On Dec 29, 5:01 pm, scsoce wrote: I have a function return a reference, Stop right there. You don't have (and can't have, in Python) a function which returns a reference that acts like a pointer in C or C+ +. Please tell us what manual, tutorial, book, blog or Usenet postin

Re: why cannot assign to function call

2008-12-29 Thread Aaron Brady
On Dec 29, 1:05 pm, Scott David Daniels wrote: > John Machin wrote: > > On Dec 29, 5:01 pm, scsoce wrote: > >> I have a function return a reference, > > > Stop right there. You don't have (and can't have, in Python) a > > function which returns a reference that acts like a pointer in C or C+ > >

Re: SQL, lite lite lite

2008-12-29 Thread Pierre Quentel
On 29 déc, 19:06, Aaron Brady wrote: > Hi all, > > About a year ago, I posted an idea I was having about thread > synchronization to the newsgroup.  However, I did not explain it well, > and I really erred on the side of brevity.  (After some finagling, Mr. > Bieber and I decided it wasn't exactly

Re: Get a list of functions in a file

2008-12-29 Thread Terry Reedy
member Basu wrote: I'm putting some utility functions in a file and then building a simple shell interface to them. Is their some way I can automatically get a list of all the functions in the file? I could wrap them in a class and then use attributes, but I'd rather leave them as simple functi

Re: How to display Chinese in a list retrieved from database via python

2008-12-29 Thread Mark Tolonen
"zxo102" wrote in message news:7e38e76a-d5ee-41d9-9ed5-73a2e2993...@w1g2000prm.googlegroups.com... On 12月29日, 下午5时06分, "Mark Tolonen" wrote: "zxo102" wrote in message news:2560a6e0-c103-46d2-aa5a-8604de4d1...@b38g2000prf.googlegroups.com... [snip] That said, learn to use Unicode string

flushing of print statements ending with comma

2008-12-29 Thread Grebekel
I have recently noticed that print statements ending with a comma are not immediately flushed. This is evident when such statement is executed before a very long operation (a big loop for instance). Example: print 'Take a walk, because this will take a while...', i = 0 while i < 10**10: i +=

Re: SQL, lite lite lite

2008-12-29 Thread Bruno Desthuilliers
Aaron Brady a écrit : Hi all, (snip) > I don't think relational data can be read and written very easily in Python. Did you try SQLAlchemy or Django's ORM ? There are some options, such as 'sqllite3', but they are not easy. 'sqllite3' statements are valid SQL expressions, which afford th

Re: why cannot assign to function call

2008-12-29 Thread Scott David Daniels
John Machin wrote: On Dec 29, 5:01 pm, scsoce wrote: I have a function return a reference, Stop right there. You don't have (and can't have, in Python) a function which returns a reference that acts like a pointer in C or C+ +. Please tell us what manual, tutorial, book, blog or Usenet postin

Re: SQL, lite lite lite

2008-12-29 Thread Ned Deily
In article , Philip Semanchuk wrote: > On Dec 29, 2008, at 1:06 PM, Aaron Brady wrote: > > I don't think relational data can be read and written very easily in > > Python. There are some options, such as 'sqllite3', but they are not > > easy. 'sqllite3' statements are valid SQL expressions, whi

Re: SQL, lite lite lite

2008-12-29 Thread Philip Semanchuk
On Dec 29, 2008, at 1:06 PM, Aaron Brady wrote: I don't think relational data can be read and written very easily in Python. There are some options, such as 'sqllite3', but they are not easy. 'sqllite3' statements are valid SQL expressions, which afford the entire power of SQL, but contrary t

SQL, lite lite lite

2008-12-29 Thread Aaron Brady
Hi all, About a year ago, I posted an idea I was having about thread synchronization to the newsgroup. However, I did not explain it well, and I really erred on the side of brevity. (After some finagling, Mr. Bieber and I decided it wasn't exactly anything groundbreaking.) But I think the brevi

Re: New Python 3.0 string formatting - really necessary?

2008-12-29 Thread walterbyrd
On Dec 21, 12:28 pm, Bruno Desthuilliers wrote: > > I can see where the new formatting might be helpful in some cases. > > But, I am not sure it's worth the cost. > > Err... _Which_ cost exactly ? Loss of backward compatibility, mainly. -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing vs thread performance

2008-12-29 Thread mk
Jarkko Torppa wrote: On the PEP371 it says "All benchmarks were run using the following: Python 2.5.2 compiled on Gentoo Linux (kernel 2.6.18.6)" Right... I overlooked that. My tests I quoted above were done on SLES 10, kernel 2.6.5. With python2.5 and pyProcessing-0.52 iTaulu:src torppa$

Python module import loop issue

2008-12-29 Thread Kottiyath
This might not be pure python question. Sorry about that. I couldnt think of any other place to post the same. I am creating a _medium_complex_ application, and I am facing issues with creating the proper module structure. This is my first application and since this is a run-of-the-mill applicatio

Re: math module for Decimals

2008-12-29 Thread rlbuvel
On Dec 29, 10:22 am, Steve Holden wrote: > Raymond L. Buvel wrote: > > Since the interest is more in extended precision than in decimal > > representation, there is another module that may be of interest. > > >http://calcrpnpy.sourceforge.net/clnum.html > > > It interfaces to the Class Library for

Re: 2to3 used in the Shootout

2008-12-29 Thread pruebauno
On Dec 23, 5:21 pm, Isaac Gouy wrote: > On Dec 23, 11:51 am, bearophileh...@lycos.com wrote: > > > They have translated the Python benchmarks of the Shootout site from > > Py2 to Py3 using 2to3: > > >http://shootout.alioth.debian.org/u32/benchmark.php?test=all〈=pyt... > > So please re-write those

Re: multiprocessing vs thread performance

2008-12-29 Thread Jarkko Torppa
On 2008-12-29, mk wrote: > janislaw wrote: > >> Ah, so there are 100 processes at time. 200secs still don't sound >> strange. > > I ran the PEP 371 code on my system (Linux) on Python 2.6.1: > > Linux SLES (9.156.44.174) [15:18] root ~/tmp/src # ./run_benchmarks.py > empty_func.py > > Importing e

Re: math module for Decimals

2008-12-29 Thread Steve Holden
Raymond L. Buvel wrote: > Since the interest is more in extended precision than in decimal > representation, there is another module that may be of interest. > > http://calcrpnpy.sourceforge.net/clnum.html > > It interfaces to the Class Library for Numbers (CLN) library to provide > both arbitrar

Re: HTML Correctness and Validators

2008-12-29 Thread Aaron Gray
"Xah Lee" wrote in message news:2fb289be-00b3-440a-b153-ca88f0ba1...@d42g2000prb.googlegroups.com... >recently i wrote a blog essay about html correctness and html >validators, with relations to the programing lang communities. I hope >programing lang fans will take more consideration on the corr

Re: Windows SSH (remote execution of commands) - Python Automation

2008-12-29 Thread Robin Becker
Narasimhan Raghu-RBQG84 wrote: Hi experts, I am looking for some information on how to automate remote login to a UNIX machine using ssh from a windows XP box. Possible way: 1. Use putty (or any other ssh client from windows XP). -- Can be automated with command line parameters. The probl

Re: why cannot assign to function call

2008-12-29 Thread Aaron Brady
On Dec 29, 12:01 am, scsoce wrote: > I have a function return a reference, and want to assign to the > reference, simply like this: >  >>def f(a) >           return a >      b = 0 >     * f( b ) = 1* > but the last line will be refused as "can't assign to function call". > In my thought , the assi

Re: math module for Decimals

2008-12-29 Thread Raymond L. Buvel
Since the interest is more in extended precision than in decimal representation, there is another module that may be of interest. http://calcrpnpy.sourceforge.net/clnum.html It interfaces to the Class Library for Numbers (CLN) library to provide both arbitrary precision floating point and comp

Re: why cannot assign to function call

2008-12-29 Thread anthony . tolle
On Dec 29, 1:01 am, scsoce wrote: > I have a function return a reference, and want to assign to the > reference, simply like this: >  >>def f(a) >           return a >      b = 0 >     * f( b ) = 1* > but the last line will be refused as "can't assign to function call". > In my thought , the assig

Re: multiprocessing vs thread performance

2008-12-29 Thread Aaron Brady
On Dec 29, 8:52 am, mk wrote: > Hello everyone, > > After readinghttp://www.python.org/dev/peps/pep-0371/I was under > impression that performance of multiprocessing package is similar to > that of thread / threading. However, to familiarize myself with both > packages I wrote my own test of spawn

Re: multiprocessing vs thread performance

2008-12-29 Thread Roy Smith
In article , Christian Heimes wrote: > You have missed an important point. A well designed application does > neither create so many threads nor processes. The creation of a thread > or forking of a process is an expensive operation. You should use a pool > of threads or processes. It's worth n

Re: multiprocessing vs thread performance

2008-12-29 Thread mk
Christian Heimes wrote: mk wrote: Am I doing smth wrong in code below? Or do I have to use multiprocessing.Pool to get any decent results? You have missed an important point. A well designed application does neither create so many threads nor processes. Except I was not developing "well des

Re: I always wonder ...

2008-12-29 Thread Hyuga
On Dec 22, 1:51 pm, Grant Edwards wrote: > On 2008-12-22, s...@pobox.com wrote: > > > ... shouldn't people who spend all their time trolling be > > doing something else: studying, working, writing patches which > > solve the problems they perceive to exist in the troll > > subject? > > I think yo

Re: multiply each element of a list by a number

2008-12-29 Thread skip
Colin> That's interesting but that's not the Colin> way timeit is documented for Python 2.5: Colin> timeit( [number=100]) That's how it works when invoked as a main program using -m. Colin> In spite of the fact that your own data doesn't support the Colin> assertion?

Re: multiprocessing vs thread performance

2008-12-29 Thread Christian Heimes
mk wrote: > Am I doing smth wrong in code below? Or do I have to use > multiprocessing.Pool to get any decent results? You have missed an important point. A well designed application does neither create so many threads nor processes. The creation of a thread or forking of a process is an expensive

Re: multiprocessing vs thread performance

2008-12-29 Thread mk
janislaw wrote: Ah, so there are 100 processes at time. 200secs still don't sound strange. I ran the PEP 371 code on my system (Linux) on Python 2.6.1: Linux SLES (9.156.44.174) [15:18] root ~/tmp/src # ./run_benchmarks.py empty_func.py Importing empty_func Starting tests ... non_threaded

Re: Windows SSH (remote execution of commands) - Python Automation

2008-12-29 Thread Cameron Laird
In article , Tino Wildenhain wrote: . . . >> I am looking for some information on how to automate remote login to a >> UNIX machine using ssh from a windows XP box. >> >> Possible way: >> >> 1. Use putty (or any other ss

Re: multiply each element of a list by a number

2008-12-29 Thread Colin J. Williams
s...@pobox.com wrote: "Colin" == Colin J Williams writes: Colin> s...@pobox.com wrote: >> For extremely short lists, but not for much else: >> >> % for n in 1 10 100 1000 1 10 ; do >> > echo "len:" $n >> > echo -n "numpy: " >> > python -m timeit -s

Re: multiprocessing vs thread performance

2008-12-29 Thread janislaw
On 29 Gru, 15:52, mk wrote: > Hello everyone, > > After readinghttp://www.python.org/dev/peps/pep-0371/I was under > impression that performance of multiprocessing package is similar to > that of thread / threading. However, to familiarize myself with both > packages I wrote my own test of spawnin

Re: game engine (as in rules not graphics)

2008-12-29 Thread Aaron Brady
On Dec 29, 4:14 am, Martin wrote: > Hi, > > 2008/12/29 Phil Runciman : > > > See: Chris Moss, Prolog++: The Power of Object-Oriented and Logic > > Programming (ISBN 0201565072) > > > This book is a pretty handy intro to an OO version Prolog produced by Logic > > Programming Associates. > > From:

multiprocessing vs thread performance

2008-12-29 Thread mk
Hello everyone, After reading http://www.python.org/dev/peps/pep-0371/ I was under impression that performance of multiprocessing package is similar to that of thread / threading. However, to familiarize myself with both packages I wrote my own test of spawning and returning 100,000 empty thr

Python-URL! - weekly Python news and links (Dec 29)

2008-12-29 Thread Gabriel Genellina
QOTW: "The fundamental economics of software development leads you to open-source software." David Rivas http://www.ddj.com/linux-open-source/212201757 Python 2.5.4 final released (replaces 2.5.3 due to a critical bug) http://groups.google.com/group/comp.lang.python/t/4042c0

Re: poblem regarding opening a html file

2008-12-29 Thread Aaron Brady
On Dec 29, 6:10 am, "Hendrik van Rooyen" wrote: > Sibtey Mehdi  wrote: > >Hi > >            I have a GUI application (wxpython) that calls another GUI > > Application. I m using os.system (cmd) >to launch>The second GUI, in the > second GUI I m trying to open the html file using the > > os.startf

Re: Read-Write Lock vs primitive Lock()

2008-12-29 Thread Aaron Brady
On Dec 29, 4:17 am, k3xji wrote: > On 29 Aralýk, 11:52, "Gabriel Genellina" > wrote: > > > En Mon, 29 Dec 2008 05:56:10 -0200, k3xji escribió: > snip > > > class wthread(threading.Thread): > > >     def run(self): > > >             try: > > >                 #GLOBAL_LOCK.acquireWrite() > > >    

Re: How to display Chinese in a list retrieved from database via python

2008-12-29 Thread zxo102
On 12月29日, 下午5时06分, "Mark Tolonen" wrote: > "zxo102" wrote in message > > news:2560a6e0-c103-46d2-aa5a-8604de4d1...@b38g2000prf.googlegroups.com... > > > I have a list in a dictionary and want to insert it into the html > > file. I test it with following scripts of CASE 1, CASE 2 and CASE 3. I >

Re: Get a list of functions in a file

2008-12-29 Thread Aaron Brady
On Dec 29, 3:50 am, "Chris Rebert" wrote: > On Sun, Dec 28, 2008 at 11:26 PM, member Basu wrote: > > I'm putting some utility functions in a file and then building a simple > > shell interface to them. Is their some way I can automatically get a list of > > all the functions in the file? I could

Re: "return" in def

2008-12-29 Thread Aaron Brady
On Dec 28, 11:56 am, Gerard Flanagan wrote: > On Dec 28, 5:19 pm, Roger wrote: > > > Hi Everyone, > [...] > > When I define a method I always include a return statement out of > > habit even if I don't return anything explicitly: > > > def something(): > >         # do something > >         retur

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-29 Thread Mark Thomas
On Dec 28, 6:22 pm, Kenneth McDonald wrote: > Ruby has a package called 'hpricot' which can perform limited xpath   > queries, and CSS selector queries. However, what makes it really   > useful is that it does a good job of handling the "broken" html that   > is so commonly found on the web. Does

Re: AttributeError: 'module' object has no attribute 'DatagramHandler' (ubuntu-8.10, python 2.5.2)

2008-12-29 Thread John Machin
On Dec 29, 11:08 pm, Tzury Bar Yochay wrote: > $ ~/devel/ice/snoip/freespeech$ python > Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > import logging > >>> logging.DatagramHandler > > Traceback

Re: Unicode encoding - ignoring errors

2008-12-29 Thread Michal Ludvig
Chris Rebert wrote: > On Mon, Dec 29, 2008 at 4:06 AM, Michal Ludvig wrote: >> Hi, >> >> in my script I have sys.stdout and sys.stderr redefined to output >> unicode strings in the current system encoding: >> >>encoding = locale.getpreferredencoding() >>sys.stdout = codecs.getwrite

Re: setup.py installs modules to a wrong place

2008-12-29 Thread Michal Ludvig
Hi Omer, > I'm seeing this on fc8 with a custom built python2.6. Not happening > with any other packages (e.g. boto). Workaround of course was just to > copy the S3 dir to /usr/local/lib/python2.6/site-packages. I've found it. The culprit was a pre-set install prefix in setup.cfg - I can't reme

Re: multiply each element of a list by a number

2008-12-29 Thread skip
> "Colin" == Colin J Williams writes: Colin> s...@pobox.com wrote: >> For extremely short lists, but not for much else: >> >> % for n in 1 10 100 1000 1 10 ; do >> > echo "len:" $n >> > echo -n "numpy: " >> > python -m timeit -s 'import numpy ; a =

  1   2   >