Re: How to programmatically exit from wsgi's serve_forever() loop

2010-12-27 Thread Ian Kelly
On 12/27/2010 6:05 PM, pyt...@bdurham.com wrote: Is it possible to programmatically exit from the wsgiref's serve_forever() loop? I tried the following, all without success: httpd.server_close() httpd.shutdown() sys.exit(1) os._exit(1) (shouldn't this always abort an application?) raise KeyboardI

ANN : PySWITCH Release – 0.1alpha

2010-12-27 Thread Godson Gera
Hi All, I am glad to announce the first alpha release of PySWITCH. http://pyswitch.sf.net The idea of PySWITCH is to offer a complete library to Python and Twisted programmers for interacting with FreeSWITCH using EventSocket interface. The target is to cover all FreeSWITCH API commands and Dia

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 28.12.2010 01:29: On 12/27/2010 4:55 PM, Stefan Behnel wrote: From my experience, SAX is only practical for very simple cases where little state is involved when extracting information from the parse events. A typical example is gathering statistics based on single tags - not a very

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 28.12.2010 03:18: By the way Stefan, please don't take any of my comments as complaints. I don't. After all, this discussion is more about the general data format than the specific tools. I use lxml more and more in my work. It's fast, functional and pretty elegant. I've writt

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Roy Smith, 28.12.2010 00:21: To go back to my earlier example of FALSE using 432 bits to store 1 bit of information, stuff like that doesn't happen in marked-up text documents. Most of the file is CDATA (do they still use that term in XML, or was that an SGML-ism only?). The markup i

Re: Language Detection Library/Code

2010-12-27 Thread Santhosh Kumar
> Hi I already Developed a language detection with Python Here is the Link. > http://code.google.com/p/langdet/ > > > > With Regards, > Santhosh V.Kumar > > -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Detection Library/Code

2010-12-27 Thread Santhosh Kumar
Hi I already Developed a language detection with Python Here is the Link. With Regards, Santhosh V.Kumar -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Alan Meyer
By the way Stefan, please don't take any of my comments as complaints. I use lxml more and more in my work. It's fast, functional and pretty elegant. I've written a lot of code on a lot of projects in my 35 year career but I don't think I've written anything anywhere near as useful to anywher

How to programmatically exit from wsgi's serve_forever() loop

2010-12-27 Thread python
Is it possible to programmatically exit from the wsgiref's serve_forever() loop? I tried the following, all without success: httpd.server_close() httpd.shutdown() sys.exit(1) os._exit(1) (shouldn't this always abort an application?) raise KeyboardInterupt (Ctrl+Break from console works) Thanks

Re: Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-27 Thread Adam Tauno Williams
On Tue, 2010-12-28 at 03:25 +0530, Anurag Chourasia wrote: > Hi All, > I have a requirement to digitally sign a XML Document using SHA1+RSA > or SHA1+DSA > Could someone give me a lead on a library that I can use to fulfill > this requirement? Never used it though. > The

Re: Partition Recursive

2010-12-27 Thread DevPlayer
# parse_url11.py # devpla...@gmail.com # 2010-12 (Dec)-27 # A brute force ugly hack from a novice programmer. # You're welcome to use the code, clean it up, make positive suggestions # for improvement. """ Parse a url string into a list using a generator. """ #special_itemMeaning = ";?:@=&#."

Re: Language Detection Library/Code

2010-12-27 Thread Shashwat Anand
On Tue, Dec 28, 2010 at 6:03 AM, Katie T wrote: > On Mon, Dec 27, 2010 at 7:10 PM, Shashwat Anand > wrote: > > Can anyone suggest a language detection library in python which works on > a > > phrase of say 2-5 words. > > Generally such libraries work by bi/trigram frequency analysis, which > mea

Re: __delitem__ "feature"

2010-12-27 Thread Ian Kelly
On 12/26/2010 11:49 AM, kj wrote: In Ian Kelly writes: On 12/26/2010 10:53 AM, kj wrote: P.S. If you uncomment the commented-out line, and comment out the last line of the __init__ method (which installs self._delitem as self.__delitem__) then *all* the deletion attempts invoke the __delite

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Alan Meyer
On 12/27/2010 6:21 PM, Roy Smith wrote: ... In the old days, they used to say, "Nobody ever got fired for buying IBM". Relational databases have pretty much gotten to that point That's _exactly_ the comparison I had in mind too. I once worked for a company that made a pitch to a big pot

Re: Language Detection Library/Code

2010-12-27 Thread Katie T
On Mon, Dec 27, 2010 at 7:10 PM, Shashwat Anand wrote: > Can anyone suggest a language detection library in python which works on a > phrase of say 2-5 words. Generally such libraries work by bi/trigram frequency analysis, which means you're going to have a fairly high error rate with such small

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Alan Meyer
On 12/27/2010 4:55 PM, Stefan Behnel wrote: ... From my experience, SAX is only practical for very simple cases where little state is involved when extracting information from the parse events. A typical example is gathering statistics based on single tags - not a very common use case. Anything

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Steven D'Aprano
On Mon, 27 Dec 2010 12:05:10 +0100, Ulrich Eckhardt wrote: > What I'm now considering is to only allow a single instance of these > objects for each set of values, similar to interned strings. What I > would gain is that I could safely compare objects for identity instead > of equality. What I'm n

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Roy Smith
Alan Meyer wrote: > On 12/26/2010 3:15 PM, Tim Harig wrote: > I agree with you but, as you say, it has become a defacto standard. As > a result, we often need to use it unless there is some strong reason to > use something else. This is certainly true. In the rarified world of usenet, we can

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Tim Delaney
On 27 December 2010 22:05, Ulrich Eckhardt wrote: > What I'm now considering is to only allow a single instance of these > objects > for each set of values, similar to interned strings. What I would gain is > that I could safely compare objects for identity instead of equality. What > I'm not ye

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Tim Harig
On 2010-12-27, Alan Meyer wrote: > On 12/26/2010 3:15 PM, Tim Harig wrote: > ... >> The problem is that XML has become such a defacto standard that it >> used automatically, without thought, even when there are much better >> alternatives available. > > I agree with you but, as you say, it has bec

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Adam Tauno Williams
On Mon, 2010-12-27 at 22:55 +0100, Stefan Behnel wrote: > Alan Meyer, 27.12.2010 21:40: > > On 12/21/2010 3:16 AM, Stefan Behnel wrote: > >> Adam Tauno Williams, 20.12.2010 20:49: > > ... > >>> You need to process the document as a stream of elements; aka SAX. > >> IMHO, this is the worst advice yo

Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-27 Thread Anurag Chourasia
Hi All, I have a requirement to digitally sign a XML Document using SHA1+RSA or SHA1+DSA Could someone give me a lead on a library that I can use to fulfill this requirement? The XML Document has values such as -BEGIN RSA PRIVATE KEY- MIIBOgIBAAJBANWzHfF5Bppe4JKlfZDqFUpNLrwNQqguw76g/jme

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 27.12.2010 21:40: On 12/21/2010 3:16 AM, Stefan Behnel wrote: Adam Tauno Williams, 20.12.2010 20:49: ... You need to process the document as a stream of elements; aka SAX. IMHO, this is the worst advice you can give. Why do you say that? I would have thought that using SAX in t

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Ulrich Eckhardt
Terry Reedy wrote: > What sort of numbers are the coordinates? If integers in a finite range, > your problem is a lot simpler than if float of indefinite precision. Yes, indeed, I could optimize the amount of data required to store the data itself, but that would require application-specific hand

Re: __delitem__ "feature"

2010-12-27 Thread kj
In <4d181afb$0$30001$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano writes: >We know it because it explains the observable facts. So does Monday-night quarterbacking... -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Alan Meyer
On 12/26/2010 3:15 PM, Tim Harig wrote: ... The problem is that XML has become such a defacto standard that it used automatically, without thought, even when there are much better alternatives available. I agree with you but, as you say, it has become a defacto standard. As a result, we often

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Alan Meyer
On 12/21/2010 3:16 AM, Stefan Behnel wrote: Adam Tauno Williams, 20.12.2010 20:49: ... You need to process the document as a stream of elements; aka SAX. IMHO, this is the worst advice you can give. Why do you say that? I would have thought that using SAX in this application is an excelle

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Terry Reedy
On 12/27/2010 6:05 AM, Ulrich Eckhardt wrote: Hi! I'm trying to solve a computational problem and of course speed and size is important there. Apart from picking the right algorithm, I came across an idea that could help speed up things and keep memory requirements down. What I have is regions d

Re: Keeping track of the N largest values

2010-12-27 Thread Stefan Sonnenberg-Carstens
Am 26.12.2010 19:51, schrieb Stefan Sonnenberg-Carstens: l = [] K = 10 while 1: a = input() if len(l) == K: l.remove(min(l)) l=[x for x in l if x < a] + [a] + [x for x in l if x > a] print l A minor fault made it into my prog: l = [0] K = 10 while 1: a = input()

Language Detection Library/Code

2010-12-27 Thread Shashwat Anand
Can anyone suggest a *language detection library* in python which works on a phrase of say 2-5 words. -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-27 Thread MRAB
On 27/12/2010 05:56, gintare wrote: Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) > F.close() As I said in my previous post, you shouldn't be using .writelines, and you shouldn't encode

Re: User input masks - Access Style

2010-12-27 Thread Adam Tauno Williams
On Sun, 2010-12-26 at 20:37 -0800, flebber wrote: > Is there anyay to use input masks in python? Similar to the function > found in access where a users input is limited to a type, length and > format. Typically this is handled by a call

Re: How to pop the interpreter's stack?

2010-12-27 Thread Ethan Furman
Steven D'Aprano wrote: On Sun, 26 Dec 2010 09:15:32 -0800, Ethan Furman wrote: Steven D'Aprano wrote: Right. But I have thought of a clever trick to get the result KJ was asking for, with the minimum of boilerplate code. Instead of this: def _pre_spam(args): if condition(args): r

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Daniel Fetchinson
>> I believe what you are looking for is (some variant of) the singleton >> pattern: >> >> http://en.wikipedia.org/wiki/Singleton_pattern > > Actually, no. What I want is the flyweight pattern instead: > > http://en.wikipedia.org/wiki/Flyweight_pattern Oh I see. I did not know about this pattern,

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-27 Thread Duncan Booth
kj wrote: >>In (almost?) all cases any objects constructed by a subclass of a >>builtin class will be of the original builtin class. > > > What I *really* would like to know is: how do *you* know this (and > the same question goes for the other responders who see this behavior > of dict as par

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Ulrich Eckhardt
Daniel Fetchinson wrote: > I believe what you are looking for is (some variant of) the singleton > pattern: > > http://en.wikipedia.org/wiki/Singleton_pattern Actually, no. What I want is the flyweight pattern instead: http://en.wikipedia.org/wiki/Flyweight_pattern ...but thank you for the appr

Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Daniel Fetchinson
> I'm trying to solve a computational problem and of course speed and size is > important there. Apart from picking the right algorithm, I came across an > idea that could help speed up things and keep memory requirements down. What > I have is regions described by min and max coordinates. At first

Re: Fw: Re: User input masks - Access Style

2010-12-27 Thread flebber
On Dec 27, 7:57 pm, linmq wrote: > > On 2010-12-27, flebber   wrote: > > >  > Is there anyay to use input masks in python? Similar to the function > >  > found in access where a users input is limited to a type, length and > >  > format. > > >  > So in my case I want to ensure that numbers are sav

Interning own classes like strings for speed and size?

2010-12-27 Thread Ulrich Eckhardt
Hi! I'm trying to solve a computational problem and of course speed and size is important there. Apart from picking the right algorithm, I came across an idea that could help speed up things and keep memory requirements down. What I have is regions described by min and max coordinates. At first

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-27 Thread Alex Willmer
On Dec 27, 6:47 am, "Mark Tolonen" wrote: > "gintare" wrote in message > > In file i find 'hyv\xe4' instead of hyv . > > When you open a file with codecs.open(), it expects Unicode strings to be > written to the file.  Don't encode them again.  Also, .writelines() expects > a list of strings.  Us

Re: round in 2.6 and 2.7

2010-12-27 Thread Mark Dickinson
On Dec 23, 6:57 pm, Hrvoje Niksic wrote: > I stumbled upon this.  Python 2.6: > > >>> round(9.95, 1) > > 10.0 > > So it seems that Python is going out of its way to intuitively round > 9.95, while the repr retains the unnecessary digits. No, Python's not doing anything clever here. Python 2.6 us

Fw: Re: User input masks - Access Style

2010-12-27 Thread linmq
> On 2010-12-27, flebber wrote: > > > Is there anyay to use input masks in python? Similar to the function > > found in access where a users input is limited to a type, length and > > format. > > > So in my case I want to ensure that numbers are saved in a basic > > format. > > 1) Currency