tornado.web ioloop add_timeout eats CPU

2012-09-02 Thread Laszlo Nagy
JavaScript clients (browsers) do long poll requests. Each request can take up to 10 seconds before the server responds. On the server side, every client has a queue of messages that needs to be sent to the client. When the long poll request comes in, the server checks if there are messages to b

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Peter Otten
wxjmfa...@gmail.com wrote: > Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit : >> Hmm, and with locale.strxfrm Python 3.3 20% slower than 3.2. > > With a memory gain = 0 since my text contains non-latin-1 characters! I can't confirm this. At least users of wide builds will

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Mark Lawrence
On 03/09/2012 06:39, wxjmfa...@gmail.com wrote: Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit : On 02.09.12 12:52, Peter Otten wrote: Ian Kelly wrote: Rewriting the example to use locale.strcoll instead: sorted(li, key=functools.cmp_to_key(locale.strcoll))

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread wxjmfauth
Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit : > On 02.09.12 12:52, Peter Otten wrote: > > > Ian Kelly wrote: > > > > > >> Rewriting the example to use locale.strcoll instead: > > > > > > sorted(li, key=functools.cmp_to_key(locale.strcoll)) > > > > > > There is a

Re: Changing a Value in List of lists

2012-09-02 Thread Rishabh Dixit
On Sunday, 2 September 2012 23:40:32 UTC+5:30, Terry Reedy wrote: > On 9/2/2012 7:17 AM, Mark Lawrence wrote: > > > On 02/09/2012 12:05, Rishabh Dixit wrote: > > >> Hi, > > >> > > >> I got it :). We should create a new list every time before adding to a > > >> list > > >> of list so that ins

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Terry Reedy
On 9/2/2012 9:54 PM, Steven D'Aprano wrote: On Sun, 02 Sep 2012 23:38:49 +0300, Serhiy Storchaka wrote: On 30.08.12 09:55, Steven D'Aprano wrote: And Python's solution uses those: UCS-2, UCS-4, and UTF-8. I see that this misconception widely spread. I am not familiar enough with the C impl

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Steven D'Aprano
On Sun, 02 Sep 2012 23:38:49 +0300, Serhiy Storchaka wrote: > On 30.08.12 09:55, Steven D'Aprano wrote: >> And Python's solution uses those: UCS-2, UCS-4, and UTF-8. > > I see that this misconception widely spread. I am not familiar enough with the C implementation to tell what Python 3.3 actua

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Steven D'Aprano
On Sun, 02 Sep 2012 11:58:08 -0700, wxjmfauth wrote: > - Unfortunately, I got opposite and even much worst results on my win > box, considering > - libfrancais is one of my module and it does a little bit more than the > std sorting tools. How do we know that the problem isn't in your module? >

PyPyODBC 0.8.3 released with improved performance and SQLAlchemy support

2012-09-02 Thread 江文
PyPyODBC - A Pure Python ctypes ODBC module Features -Pure Python, compatible with IronPython and PyPy (tested on Win32) -Almost totally same usage as pyodbc You can simply try pypyodbc in your existing pyodbc powered script with the following changes: #import pyodbc

Re: [pyxl] xlrd-0.8.0 .xlsx formatting_info=True not implemented

2012-09-02 Thread python-excel
Albert-Jan Roskam wrote: > Hi, > > As a work-around, you could use the CRAN R package XLConnect, using > RPy or RPy2, to do what you want. IIRC it's based on Java, so it's not > extremely fast. > http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf > This is another package I

Re: newbie ``print`` question

2012-09-02 Thread MRAB
On 03/09/2012 00:33, gwhite wrote: On Sep 2, 3:43 pm, MRAB wrote: On 02/09/2012 21:58, gwhite wrote: > On Sep 2, 1:16 pm, Dave Angel wrote: >> On 09/02/2012 03:50 PM, gwhite wrote: >> > On Sep 2, 12:43 pm, Dave Angel wrote: >> >> On 09/02/2012 03:34 PM, gwhite wrote: >> >>> >> >>> b

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 3:43 pm, MRAB wrote: > On 02/09/2012 21:58, gwhite wrote: > > > > > > > > > On Sep 2, 1:16 pm, Dave Angel wrote: > >> On 09/02/2012 03:50 PM, gwhite wrote: > > >> > On Sep 2, 12:43 pm, Dave Angel wrote: > >> >> On 09/02/2012 03:34 PM, gwhite wrote: > > >> >>> > >> >>> btw, I also thou

Re: newbie ``print`` question

2012-09-02 Thread Chris Angelico
On Mon, Sep 3, 2012 at 9:20 AM, gwhite wrote: > I guess you're saying 3.x will just ignore: > > from __future__ import print_function > > I'll risk being silly, and thus ask: but what if when I get to 3.x > there is no __future__, as it is now "present?" Do I need to strip > out the line? > > Wha

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 2:47 pm, Chris Angelico wrote: > On Mon, Sep 3, 2012 at 7:18 AM, gwhite wrote: > > Thanks again, Terry.  There is a lot to the language, I am finding > > out.  I am a HW engineer, not really a programmer.  Python seems a lot > > more sophisticated than MATLAB. > > > I'm kinda thinking `

Re: newbie ``print`` question

2012-09-02 Thread MRAB
On 02/09/2012 21:58, gwhite wrote: On Sep 2, 1:16 pm, Dave Angel wrote: On 09/02/2012 03:50 PM, gwhite wrote: > On Sep 2, 12:43 pm, Dave Angel wrote: >> On 09/02/2012 03:34 PM, gwhite wrote: >>> >>> btw, I also thought the default "add a CR LF" to the end was odd too. >>> But at lea

Re: newbie ``print`` question

2012-09-02 Thread Chris Angelico
On Mon, Sep 3, 2012 at 7:18 AM, gwhite wrote: > Thanks again, Terry. There is a lot to the language, I am finding > out. I am a HW engineer, not really a programmer. Python seems a lot > more sophisticated than MATLAB. > > I'm kinda thinking `write` is likely to be a little more "stable" than >

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Serhiy Storchaka
On 02.09.12 23:38, Serhiy Storchaka wrote: Indexing is O(0) for any string. Typo. O(1) -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 1:49 pm, Terry Reedy wrote: > On 9/2/2012 3:26 PM, gwhite wrote: > > > On the "rework" thing, yes, I suppose I could construct the line as a > > single string prior to print.    There would be things like `for` > > loops and conditionals to do so.  That isn't so unusual. > > The usual id

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 1:37 pm, Dennis Lee Bieber wrote: > On Sun, 2 Sep 2012 10:23:53 -0700 (PDT), gwhite > declaimed the following in gmane.comp.python.general: > > > > > "A space is written before each object is (converted and) written, > > unless the output system believes it is positioned at the beginnin

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 1:16 pm, Dave Angel wrote: > On 09/02/2012 03:50 PM, gwhite wrote: > > > > > > > > > > > On Sep 2, 12:43 pm, Dave Angel wrote: > >> On 09/02/2012 03:34 PM, gwhite wrote: > > >>> > >>> btw, I also thought the default "add a CR LF" to the end was odd too. > >>> But at least that one had

Re: PipeController v0.1 - experimental tool to simulate simple UNIX-style pipes in Python

2012-09-02 Thread vasudevram
On Monday, September 3, 2012 1:05:03 AM UTC+5:30, vasudevram wrote: > > To Ian Kelly: > > No, that deals with actual Unix pipes. This appears to be about pipelined > > processing within a single program and not IPC; the description "Unix-like" > > is a bit misleading, IMO. > I guess it can be int

Re: newbie ``print`` question

2012-09-02 Thread Terry Reedy
On 9/2/2012 3:26 PM, gwhite wrote: On the "rework" thing, yes, I suppose I could construct the line as a single string prior to print.There would be things like `for` loops and conditionals to do so. That isn't so unusual. The usual idiom is to construct a list of pieces and then join wit

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Serhiy Storchaka
On 30.08.12 09:55, Steven D'Aprano wrote: And Python's solution uses those: UCS-2, UCS-4, and UTF-8. I see that this misconception widely spread. In fact Python 3.3 uses four kinds of ready strings. * ASCII. All codes <= U+007F. * UCS1. All codes <= U+00FF, at least one code > U+007F. * UCS2

Re: stuck in files!!

2012-09-02 Thread Dave Angel
On 09/02/2012 04:07 PM, me wrote: > Didn't see the post date on my reader haha. Sorry about that. > Well, i see you're also posting responses to recent messages. Great. But please use reply with a proper mail program; your messages are all brand new threads. And could you fix your email address

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Terry Reedy
On 9/2/2012 3:45 PM, Michael Torrie wrote: In the worst case, Python's strings are as slow as Go because Python does the exact same thing as Go, but chooses between three encodings instead of just one. Best case scenario, Python's strings could be much faster than Go's because indexing through

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 1:24 PM, Mark Lawrence wrote: > On 02/09/2012 20:58, me wrote: >> >> Well you can convert the ints to str then concatenate them. >> >> print "1" + "2" >> > > Please post other parts of the thread so people can get the context or don't > bother posting at all, thanks. Please

Re: newbie ``print`` question

2012-09-02 Thread Mark Lawrence
On 02/09/2012 20:58, me wrote: Well you can convert the ints to str then concatenate them. print "1" + "2" Please post other parts of the thread so people can get the context or don't bother posting at all, thanks. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/pyth

Re: newbie ``print`` question

2012-09-02 Thread Dave Angel
On 09/02/2012 03:50 PM, gwhite wrote: > On Sep 2, 12:43 pm, Dave Angel wrote: >> On 09/02/2012 03:34 PM, gwhite wrote: >> >>> >>> btw, I also thought the default "add a CR LF" to the end was odd too. >>> But at least that one had a simple way out. >> But it (print on Python 2.x) doesn't, unless y

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 11:33 am, Terry Reedy wrote: > On 9/2/2012 1:23 PM, gwhite wrote: > > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > You have discovered why print is a function in 3.x. >  >>> print(1, 2, sep=

Re: stuck in files!!

2012-09-02 Thread me
Didn't see the post date on my reader haha. Sorry about that. -- http://mail.python.org/mailman/listinfo/python-list

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Dave Angel
On 09/02/2012 03:45 PM, Michael Torrie wrote: > : > In the worst case, Python's strings are as slow as Go because Python > does the exact same thing as Go, but chooses between three encodings > instead of just one. Best case scenario, Python's strings could be > much faster than Go's because indexi

Re: newbie ``print`` question

2012-09-02 Thread me
Well you can convert the ints to str then concatenate them. print "1" + "2" -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 12:43 pm, Dave Angel wrote: > On 09/02/2012 03:34 PM, gwhite wrote: > > > > > > btw, I also thought the default "add a CR LF" to the end was odd too. > > But at least that one had a simple way out. > > But it (print on Python 2.x) doesn't, unless you're stuck on Windows. > And even then

Re: How to print a number as if in the python interpreter?

2012-09-02 Thread me
Use repr() print(repr(sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]))) -- http://mail.python.org/mailman/listinfo/python-list

Re: stuck in files!!

2012-09-02 Thread Dave Angel
On 09/02/2012 03:36 PM, me wrote: > The best you can do is pipe a string to a .txt document then pipe it again to > a wordpad document. You should be able to do that easily with file and open() > If your reply is going to break the thread, and if the thread has been stale almost a month, then it

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 10:45 am, Joel Goldstick wrote: > On Sun, Sep 2, 2012 at 1:23 PM, gwhite wrote: > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > > See the space in between the 1 and the 2 at the output print

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Michael Torrie
On 09/02/2012 12:58 PM, wxjmfa...@gmail.com wrote: > My rationale: very simple. > > 1) I never heard about something better than sticking with one > of the Unicode coding scheme. (genreral theory) > 2) I am not at all convinced by the "new" Py 3.3 algorithm. I'm not the > only one guy, who noticed

Re: newbie ``print`` question

2012-09-02 Thread Dave Angel
On 09/02/2012 03:34 PM, gwhite wrote: > > > btw, I also thought the default "add a CR LF" to the end was odd too. > But at least that one had a simple way out. But it (print on Python 2.x) doesn't, unless you're stuck on Windows. And even then, you can prevent it by using a 'b' in the mode. --

Re: stuck in files!!

2012-09-02 Thread me
The best you can do is pipe a string to a .txt document then pipe it again to a wordpad document. You should be able to do that easily with file and open() -- http://mail.python.org/mailman/listinfo/python-list

Re: PipeController v0.1 - experimental tool to simulate simple UNIX-style pipes in Python

2012-09-02 Thread vasudevram
On Saturday, September 1, 2012 9:02:33 PM UTC+5:30, Ramchandra Apte wrote: > On Friday, 31 August 2012 03:27:54 UTC+5:30, vasudevram wrote: > > > I wrote PipeController recently to experiment with doing UNIX-style pipes > > in Python. > > > Doesn't the pipes module already do this? Yes. As Ia

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 12:26 pm, gwhite wrote: > On Sep 2, 10:55 am, Chris Rebert wrote: > > > > > > > > > > > On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > > > I can't figure out how to stop the "add a space at the beginning" > > > behavior of the print function. > > > print 1,;print 2, > > > 1 2 >

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 10:55 am, Chris Rebert wrote: > On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > > See the space in between the 1 and the 2 at the output print

Re: running Lua in Python

2012-09-02 Thread Stefan Behnel
Arnaud Delobelle, 02.09.2012 21:17: > On 2 September 2012 19:42, Stefan Behnel wrote: >> Arnaud Delobelle, 02.09.2012 20:34: >>> On 2 September 2012 10:49, Arnaud Delobelle wrote: On 2 September 2012 10:39, Alec Taylor wrote: > http://pypi.python.org/pypi/lupa I'll check this out

Re: how to interact with Windows cmd?

2012-09-02 Thread me
Not sure but have you tried using functions from the os library? For example you could use execl() to execute your commands and pipe the output somewhere-stdin in your case. -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 11:33 am, Terry Reedy wrote: > On 9/2/2012 1:23 PM, gwhite wrote: > > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > You have discovered why print is a function in 3.x. >  >>> print(1, 2, sep=

Re: running Lua in Python

2012-09-02 Thread Arnaud Delobelle
On 2 September 2012 19:42, Stefan Behnel wrote: > Arnaud Delobelle, 02.09.2012 20:34: >> On 2 September 2012 10:49, Arnaud Delobelle wrote: >>> On 2 September 2012 10:39, Alec Taylor wrote: http://pypi.python.org/pypi/lupa >>> >>> I'll check this out, thanks. >> >> Mmh it seems to be lua 5.1

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread wxjmfauth
Le dimanche 2 septembre 2012 11:07:35 UTC+2, Ian a écrit : > On Sun, Sep 2, 2012 at 1:36 AM, wrote: > > > I still remember my thoughts when I read the PEP 393 > > > discussion: "this is not logical", "they do no understand > > > typography", "atomic character ???", ... > > > > That would in

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 10:55 am, Chris Rebert wrote: > On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > > See the space in between the 1 and the 2 at the output print

Re: newbie ``print`` question

2012-09-02 Thread gwhite
On Sep 2, 10:49 am, mblume wrote: > Am Sun, 02 Sep 2012 10:23:53 -0700 schrieb gwhite: > > > > > > > > > > > I can't figure out how to stop the "add a space at the beginning" > > behavior of the print function. > > print 1,;print 2, > > 1 2 > > > See the space in between the 1 and the 2 at th

Re: running Lua in Python

2012-09-02 Thread Stefan Behnel
Arnaud Delobelle, 02.09.2012 20:34: > On 2 September 2012 10:49, Arnaud Delobelle wrote: >> On 2 September 2012 10:39, Alec Taylor wrote: >>> http://pypi.python.org/pypi/lupa >> >> I'll check this out, thanks. > > Mmh it seems to be lua 5.1 and more importantly it seems to require a > custom build

Re: running Lua in Python

2012-09-02 Thread Arnaud Delobelle
On 2 September 2012 10:49, Arnaud Delobelle wrote: > On 2 September 2012 10:39, Alec Taylor wrote: >> http://pypi.python.org/pypi/lupa > > I'll check this out, thanks. Mmh it seems to be lua 5.1 and more importantly it seems to require a custom build of Python, which I don't want. So it seems t

Re: newbie ``print`` question

2012-09-02 Thread Terry Reedy
On 9/2/2012 1:23 PM, gwhite wrote: I can't figure out how to stop the "add a space at the beginning" behavior of the print function. print 1,;print 2, 1 2 You have discovered why print is a function in 3.x. >>> print(1, 2, sep='') 12 >>> print(1, end=''); print(2, end='') 12 In 2.6 or 2.7,

Re: Changing a Value in List of lists

2012-09-02 Thread Terry Reedy
On 9/2/2012 7:17 AM, Mark Lawrence wrote: On 02/09/2012 12:05, Rishabh Dixit wrote: Hi, I got it :). We should create a new list every time before adding to a list of list so that instead repeating the reference a new reference generated every time. Please don't top post on this list as it o

Re: [2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Terry Reedy
On 9/2/2012 6:36 AM, Gilles wrote: On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote: (snip) Found it: #rewrite lines to new file output = open('output.txt','w') for line in textlines: #edit each line line = "just a test" output.write("%s" % line) output.close() If y

Re: newbie ``print`` question

2012-09-02 Thread Chris Rebert
On Sun, Sep 2, 2012 at 10:23 AM, gwhite wrote: > I can't figure out how to stop the "add a space at the beginning" > behavior of the print function. > print 1,;print 2, > 1 2 > > See the space in between the 1 and the 2 at the output print to the > command console? > > The help for print is:

Re: newbie ``print`` question

2012-09-02 Thread mblume
Am Sun, 02 Sep 2012 10:23:53 -0700 schrieb gwhite: > I can't figure out how to stop the "add a space at the beginning" > behavior of the print function. > print 1,;print 2, > 1 2 > > See the space in between the 1 and the 2 at the output print to the > command console? > > The help for pri

Re: newbie ``print`` question

2012-09-02 Thread Joel Goldstick
On Sun, Sep 2, 2012 at 1:23 PM, gwhite wrote: > I can't figure out how to stop the "add a space at the beginning" > behavior of the print function. > print 1,;print 2, > 1 2 > > See the space in between the 1 and the 2 at the output print to the > command console? > > The help for print is: >

Re: set and dict iteration

2012-09-02 Thread Aaron Brady
On Monday, August 27, 2012 2:17:45 PM UTC-5, Ian wrote: > On Thu, Aug 23, 2012 at 10:49 AM, Aaron Brady wrote: > > > The patch for the above is only 40-60 lines. However it introduces two new > > concepts. > > > > Is there a link to the patch? Please see below. It grew somewhat during deve

Re: newbie ``print`` question

2012-09-02 Thread Mark Lawrence
On 02/09/2012 18:23, gwhite wrote: I can't figure out how to stop the "add a space at the beginning" behavior of the print function. print 1,;print 2, 1 2 See the space in between the 1 and the 2 at the output print to the command console? The help for print is: "A space is written before e

newbie ``print`` question

2012-09-02 Thread gwhite
I can't figure out how to stop the "add a space at the beginning" behavior of the print function. >>> print 1,;print 2, 1 2 See the space in between the 1 and the 2 at the output print to the command console? The help for print is: "A space is written before each object is (converted and) writt

Re: Logging handler: No output

2012-09-02 Thread Vinay Sajip
Florian Lindner xgm.de> writes: > But neither the FileHandler nor the StreamHandler produce any actual output. > The file is being created but stays empty. If I use a print output in the > while loop it works, so output is catched and the applications stdout in > working. But why the logger pr

Re: [Twisted-Python] Twisted 12.2.0 released

2012-09-02 Thread Laurens Van Houtven
Congratulations to the entire team, particularly Ashwini, and thank you for an awesome release manager job well done, Ashwini :) On Sat, Sep 1, 2012 at 3:47 PM, Ashwini Oruganti wrote: > On behalf of Twisted Matrix Laboratories, I am honored to announce the > release of Twisted 12.2. > > Highli

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Mark Lawrence
On 02/09/2012 14:48, Ramchandra Apte wrote: please make it *heavily optimized* machine code Goes without saying. First thing I'll concentrate on is removing superfluous newlines sent by crappy mail clients or similar. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo

Re: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

2012-09-02 Thread Peter Otten
Token Type wrote: > I wrote codes to add 'like' at the end of every 3 word in a nltk text as follows: > > >>> text = nltk.corpus.brown.words(categories = 'news') > >>> def hedge(text): > for i in range(3,len(text),4): > new_text = text.insert(i, 'like') > return n

Re: Fwd: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

2012-09-02 Thread Dave Angel
On 09/02/2012 09:06 AM, John H. Li wrote: > First, thanks very much for your kind help. > > 1)Further more, I test the function of insert. It did work as follows: > text = ['The', 'Fulton', 'County', 'Grand'] text.insert(3,'like') text > ['The', 'Fulton', 'County', 'like', 'Grand'] >

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Ramchandra Apte
On Sunday, 2 September 2012 17:53:16 UTC+5:30, Mark Lawrence wrote: > On 02/09/2012 13:00, Serhiy Storchaka wrote: > > > On 02.09.12 12:52, Peter Otten wrote: > > >> Ian Kelly wrote: > > >> > > >>> Rewriting the example to use locale.strcoll instead: > > >> > > >> sorted(li, key=functool

Re: py2c - an open source Python to C/C++ is looking for developers

2012-09-02 Thread Ramchandra Apte
On Sunday, 2 September 2012 12:53:35 UTC+5:30, Serhiy Storchaka wrote: > On 02.09.12 06:15, Ramchandra Apte wrote: > > > It converts to *pure* C/C++ *without* using Python or its API so that it > > can be the same speed as C/C++ > > > > How is it implemented long integers? py2c has been jus

Fwd: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

2012-09-02 Thread John H. Li
First, thanks very much for your kind help. 1)Further more, I test the function of insert. It did work as follows: >>> text = ['The', 'Fulton', 'County', 'Grand'] >>> text.insert(3,'like') >>> text ['The', 'Fulton', 'County', 'like', 'Grand'] >>> 2) I tested the text from nltk. It is list actual

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Roy Smith
In article , Mark Lawrence wrote: > On 02/09/2012 13:00, Serhiy Storchaka wrote: > > On 02.09.12 12:52, Peter Otten wrote: > >> Ian Kelly wrote: > >> > >>> Rewriting the example to use locale.strcoll instead: > >> > >> sorted(li, key=functools.cmp_to_key(locale.strcoll)) > >> > >> There is a

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Mark Lawrence
On 02/09/2012 13:00, Serhiy Storchaka wrote: On 02.09.12 12:52, Peter Otten wrote: Ian Kelly wrote: Rewriting the example to use locale.strcoll instead: sorted(li, key=functools.cmp_to_key(locale.strcoll)) There is also locale.strxfrm() which you can use directly: sorted(li, key=locale.s

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Serhiy Storchaka
On 02.09.12 12:52, Peter Otten wrote: Ian Kelly wrote: Rewriting the example to use locale.strcoll instead: sorted(li, key=functools.cmp_to_key(locale.strcoll)) There is also locale.strxfrm() which you can use directly: sorted(li, key=locale.strxfrm) Hmm, and with locale.strxfrm Python

Re: Logging handler: No output

2012-09-02 Thread Paul Rubin
Florian Lindner writes: > The file is being created but stays empty. If I use a print output in the > while loop it works, so output is catched and the applications stdout in > working. But why the logger proclog catching nothing? I don't see you setting the log level anyplace in that sample, a

Re: Changing a Value in List of lists

2012-09-02 Thread Mark Lawrence
On 02/09/2012 12:05, Rishabh Dixit wrote: Hi, I got it :). We should create a new list every time before adding to a list of list so that instead repeating the reference a new reference generated every time. Please don't top post on this list as it often destroys the context, thanks. -- Chee

Logging handler: No output

2012-09-02 Thread Florian Lindner
Hello, I have a class method that executes a subprocess. There are two loggers in the class, self.logger for general logging and proclog for process output (stdout & stderr) logging which should go to stdout and a file: def start_process(self, command, no_shlex=False, raise_excpt=True,

Re: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

2012-09-02 Thread Dave Angel
On 09/02/2012 05:39 AM, Token Type wrote: > I wrote codes to add 'like' at the end of every 3 word in a nltk text as > follows: > text = nltk.corpus.brown.words(categories = 'news') def hedge(text): > for i in range(3,len(text),4): > new_text = text.insert(i, 'like')

Re: Changing a Value in List of lists

2012-09-02 Thread Rishabh Dixit
Hi, I got it :). We should create a new list every time before adding to a list of list so that instead repeating the reference a new reference generated every time. >>> mat=[[0]*5 for i in range(5)] >>> mat[1][2]+=1 >>> mat [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0,

Re: Changing a Value in List of lists

2012-09-02 Thread Rishabh Dixit
Hi Chris, Thanks for your reply. I tried this - >>> ls=[0 for i in range(5)] >>> mat=[ls for i in range(5)] >>> mat[1][2]+=1 >>> mat [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]] I guess here also the same issue is there as ls refers to one list that is be

Re: [2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Mark Lawrence
On 02/09/2012 11:36, Gilles wrote: On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote: (snip) Found it: #rewrite lines to new file output = open('output.txt','w') for line in textlines: #edit each line line = "just a test" output.write("%s" % line) output.close() IMH

Re: [2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Gilles
On Sun, 02 Sep 2012 12:19:02 +0200, Gilles wrote: (snip) Found it: #rewrite lines to new file output = open('output.txt','w') for line in textlines: #edit each line line = "just a test" output.write("%s" % line) output.close() -- http://mail.python.org/mailman/listinfo

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Mark Lawrence
I've found the white paper which gives the technical basis for the claims made by jmf so thought I'd better share in order to explain his rationale. http://www.montypython.net/scripts/right-think.php -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list

[2.5.1] Read each line from txt file, replace, and save?

2012-09-02 Thread Gilles
Hello This is a newbie question. I need to read a text file into a variable, loop through each line and use a regex to substitute some items within the line, and save the whole variable into a new text file. This triggers an error when I save the modified variable that contains all the lines: ==

Re: Changing a Value in List of lists

2012-09-02 Thread Chris Angelico
On Sun, Sep 2, 2012 at 7:44 PM, Rishabh Dixit wrote: > > Hi all, > > I have a doubt regarding how the list work in following case- > ls=[[0]*5]*5 ls[1][1]+=1 ls > [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, > 0, 0, 0]] > > > Here, according to me only

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Peter Otten
Ian Kelly wrote: > Rewriting the example to use locale.strcoll instead: sorted(li, key=functools.cmp_to_key(locale.strcoll)) There is also locale.strxfrm() which you can use directly: sorted(li, key=locale.strxfrm) -- http://mail.python.org/mailman/listinfo/python-list

Re: running Lua in Python

2012-09-02 Thread Arnaud Delobelle
On 2 September 2012 10:39, Alec Taylor wrote: > Or you can use a module made for this task: > > http://labix.org/lunatic-python As I said in my original message, I couldn't get this to work. > http://pypi.python.org/pypi/lupa I'll check this out, thanks. -- Arnaud -- http://mail.python.org/m

Re: running Lua in Python

2012-09-02 Thread Stefan Behnel
Arnaud Delobelle, 02.09.2012 11:04: > I'm looking for a way to run Lua scripts in Python, and also send and > receive data between the two. Something like lunatic-python [1] would > be ideal. However, so far I haven't been able to build it on the > machines it's supposed to run on (macs with OS X

Changing a Value in List of lists

2012-09-02 Thread Rishabh Dixit
Hi all, I have a doubt regarding how the list work in following case- >>> ls=[[0]*5]*5 >>> ls[1][1]+=1 >>> ls [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0]] Here, according to me only one value in ls should be incremented but it is increasing 1 value in al

The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

2012-09-02 Thread Token Type
I wrote codes to add 'like' at the end of every 3 word in a nltk text as follows: >>> text = nltk.corpus.brown.words(categories = 'news') >>> def hedge(text): for i in range(3,len(text),4): new_text = text.insert(i, 'like') return new_text[:50] >>> hedge(text) Tr

Re: running Lua in Python

2012-09-02 Thread Alec Taylor
Or you can use a module made for this task: http://labix.org/lunatic-python http://pypi.python.org/pypi/lupa On Sun, Sep 2, 2012 at 7:24 PM, Ian Kelly wrote: > > On Sun, Sep 2, 2012 at 3:04 AM, Arnaud Delobelle wrote: > > Hi all, > > > > I'm looking for a way to run Lua scripts in Python, and

Re: running Lua in Python

2012-09-02 Thread Ian Kelly
On Sun, Sep 2, 2012 at 3:04 AM, Arnaud Delobelle wrote: > Hi all, > > I'm looking for a way to run Lua scripts in Python, and also send and > receive data between the two. Something like lunatic-python [1] would > be ideal. However, so far I haven't been able to build it on the > machines it's s

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Ian Kelly
On Sun, Sep 2, 2012 at 1:36 AM, wrote: > I still remember my thoughts when I read the PEP 393 > discussion: "this is not logical", "they do no understand > typography", "atomic character ???", ... That would indicate one of two possibilities. Either: 1) Everybody in the PEP 393 discussion exce

running Lua in Python

2012-09-02 Thread Arnaud Delobelle
Hi all, I'm looking for a way to run Lua scripts in Python, and also send and receive data between the two. Something like lunatic-python [1] would be ideal. However, so far I haven't been able to build it on the machines it's supposed to run on (macs with OS X Lion) and it seems to be dormant.

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread Mark Lawrence
On 02/09/2012 08:36, wxjmfa...@gmail.com wrote: Le jeudi 30 août 2012 17:01:50 UTC+2, Antoine Pitrou a écrit : I honestly suggest you shut up until you have a clue. Désolé Antoine, I have not the knowledge to dive in the Python code, but I know what is a character. You're a character, and

Re: py2c - an open source Python to C/C++ is looking for developers

2012-09-02 Thread Mark Lawrence
On 02/09/2012 07:16, Ramchandra Apte wrote: On Sunday, 2 September 2012 11:18:38 UTC+5:30, Michael Torrie wrote: On 09/01/2012 09:15 PM, Ramchandra Apte wrote: It converts to *pure* C/C++ *without* using Python or its API so that it can be the same speed as C/C++ Sounds like a fun projec

Re: Async client for PostgreSQL?

2012-09-02 Thread Laszlo Nagy
Hmm, I was suggesting that you could replace the whole DB driver with a webservice implemented with twisted, if you rule out threads then with ampoule doing it with a process pool and consume this webservice with the tornado side asynchronously. I see. I'm sorry, I misunderstood. So this would

Re: Flexible string representation, unicode, typography, ...

2012-09-02 Thread wxjmfauth
Le jeudi 30 août 2012 17:01:50 UTC+2, Antoine Pitrou a écrit : > > > I honestly suggest you shut up until you have a clue. > Désolé Antoine, I have not the knowledge to dive in the Python code, but I know what is a character. The coding of the characters is a domain per se, independent from th

Re: py2c - an open source Python to C/C++ is looking for developers

2012-09-02 Thread Serhiy Storchaka
On 02.09.12 06:15, Ramchandra Apte wrote: It converts to *pure* C/C++ *without* using Python or its API so that it can be the same speed as C/C++ How is it implemented long integers? -- http://mail.python.org/mailman/listinfo/python-list