RE: A fast way to read last line of gzip archive ?

2009-05-23 Thread Barak, Ron
> -Original Message- > From: MRAB [mailto:goo...@mrabarnett.plus.com] > Sent: Thursday, May 21, 2009 19:02 > To: 'python-list@python.org' > Subject: Re: A fast way to read last line of gzip archive ? > > Barak, Ron wrote: > > Hi, > > > > I need to read the end of a 20 MB gzip archive

Need Help

2009-05-23 Thread abosalim
#Gui import re, collections from Tkinter import * from nltk_lite import tokenize def words(text): return re.findall('[a-z]+', text.lower()) def train(features): model = collections.defaultdict(lambda: 1) for f in features: model[f] += 1 return model NWORDS = train(words(fi

Re: Problems with sys.stout.flush()

2009-05-23 Thread AK
Joel Ross wrote: Rhodri James wrote: On Sat, 23 May 2009 18:19:11 +0100, Joel Ross wrote: Now I can move onto next one. Except that you still have the interesting issue that your environment isn't responding to '\r' correctly, which worries me rather. Or did you never test that? Yeah I ga

Extending C++ class in python

2009-05-23 Thread nazia
Hi all, I'm a newbie in Python and need help. Can anyone help me by explaining the steps of extending a C++ class in Python with a simple example? I'm not interested to use SWIG like tools. Thanks for your time. -Nazia -- http://mail.python.org/mailman/listinfo/python-list

[Announcement] PyISAPIe version 1.1.0 Release Candidate 2

2009-05-23 Thread Phillip Sitbon
Hello all, I've recently revived the Python ISAPI Extension (PyISAPIe) project and thought I'd share the newest release with you, version 1.1.0-rc2. Development in bringing Python to Windows servers has been slow these days, so hopefully this project can continue to fill a niche for those who nee

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Mel wrote: Joel Ross wrote: Rhodri James wrote: [ ... ] Except that you still have the interesting issue that your environment isn't responding to '\r' correctly, which worries me rather. Or did you never test that? Yeah I gave the "\r" a go and it kept printing out on a new line I will lo

Re: from __future__ import absolute_import issue

2009-05-23 Thread Gabriel Genellina
En Sat, 23 May 2009 12:32:24 -0300, LittleGrasshopper escribió: On May 22, 12:42 am, "Gabriel Genellina" wrote: En Wed, 20 May 2009 20:18:02 -0300, LittleGrasshopper   escribió: > It appears that either absolute imports (or my brain) aren't working. > Given a module string.py which is in

Re: When does the escape character work within raw strings?

2009-05-23 Thread Steven D'Aprano
On Sat, 23 May 2009 14:05:10 -0700, walterbyrd wrote: > On May 22, 12:22 pm, "Rhodri James" >> How do you know how a string object is going to be treated by any given >> function?  Read the Fine Manual for that function. > > So am I to understand that there is no consistency in string handling >

Re: Problems with sys.stout.flush()

2009-05-23 Thread Mel
Joel Ross wrote: > Rhodri James wrote: [ ... ] >> Except that you still have the interesting issue that your environment >> isn't responding to '\r' correctly, which worries me rather. Or did >> you never test that? > Yeah I gave the "\r" a go and it kept printing out on a new line I will > look

Re: wxpython and zoom/pan image

2009-05-23 Thread Dave Angel
rzzzwil...@gmail.com wrote: Hi, I've googled for this, but can only find things like openlayers that is a web-based javascript solution. I need to display an image at various zoom levels and want to allow the user to pan around in the Google maps style, that is, left-click hold and drag. The c

Re: wxPython gurus, please help

2009-05-23 Thread Benjamin Kaplan
On Sat, May 23, 2009 at 6:55 PM, Jive Dadson wrote: > I have an application that opens an image file of the user's choice. I > have an exception handler for the case that the user selected a bad or > unsupported image file. My code is catching the exception, but > unfortunately for me, after

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Dennis Lee Bieber wrote: flush() is working perfectly fine -- it says transmit any data still held within internal buffers. It is NOT a "clear screen", "clear line" terminal command. I was mistaken about the sys.stout.flush(). I understand it a little more now thanks -- http://mail.py

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Rhodri James wrote: On Sat, 23 May 2009 18:19:11 +0100, Joel Ross wrote: Now I can move onto next one. Except that you still have the interesting issue that your environment isn't responding to '\r' correctly, which worries me rather. Or did you never test that? Yeah I gave the "\r" a go a

wxpython and zoom/pan image

2009-05-23 Thread rzzzwilson
Hi, I've googled for this, but can only find things like openlayers that is a web-based javascript solution. I need to display an image at various zoom levels and want to allow the user to pan around in the Google maps style, that is, left-click hold and drag. The code should also action double-

wxPython gurus, please help

2009-05-23 Thread Jive Dadson
I have an application that opens an image file of the user's choice. I have an exception handler for the case that the user selected a bad or unsupported image file. My code is catching the exception, but unfortunately for me, after I exit the except-clause, wxPython is popping up its own

Re: Cursor movement question

2009-05-23 Thread Jive Dadson
Aahz wrote: In article , Jive Dadson wrote: Gosh, you guys are slow. :-) I figured it out. Perhaps you could post the solution for posterity's sake? The double secret magic encantation is "WarpPointer." Unfortunately, it does not work in a plain vanilla ScrolledWindow. ScrolledWindow cap

Re: When does the escape character work within raw strings?

2009-05-23 Thread Stephen Hansen
> > > How do you know how a string object is going to be treated by any > > given function? Read the Fine Manual for that function. > > So am I to understand that there is no consistency in string handling > throughout the standard modules/objects/methods? > > Seems to make python a lot more compl

Re: When does the escape character work within raw strings?

2009-05-23 Thread Rhodri James
On Sat, 23 May 2009 22:05:10 +0100, walterbyrd wrote: On May 22, 12:22 pm, "Rhodri James" How do you know how a string object is going to be treated by any given function?  Read the Fine Manual for that function. So am I to understand that there is no consistency in string handling through

Re: Problems with sys.stout.flush()

2009-05-23 Thread Rhodri James
On Sat, 23 May 2009 18:19:11 +0100, Joel Ross wrote: Now I can move onto next one. Except that you still have the interesting issue that your environment isn't responding to '\r' correctly, which worries me rather. Or did you never test that? -- Rhodri James *-* Wildebeeste Herder to the Ma

Re: Abstract Classes

2009-05-23 Thread Rhodri James
On Sat, 23 May 2009 12:02:00 +0100, Tim Cook wrote: I am implementing a set of specifications that were designed to be OO language neutral. Several classes are specified as being abstract; so therefore there should be no instances of them, correct? However in the classes that are subclasses

Problems with StaticBitmaps and events

2009-05-23 Thread Water Bottle
Hi, I'm new to wxpython and I created a test program. So far, it works, but there are some problems with it. For some reason, I get a small box in the top left corner. Not sure why that's happening. Also, I can't get my picture to bind to my Play(). Lastly, do you recommend using StaticBitmap as

Re: When does the escape character work within raw strings?

2009-05-23 Thread Robert Kern
On 2009-05-23 16:05, walterbyrd wrote: On May 22, 12:22 pm, "Rhodri James" How do you know how a string object is going to be treated by any given function? Read the Fine Manual for that function. So am I to understand that there is no consistency in string handling throughout the standard mo

Re: Optimizing math functions

2009-05-23 Thread Robert Kern
On 2009-05-23 08:22, Esmail wrote: Hello all, I would like to maximize or minimize a given math function over a specific set of values, in Python preferably. I was checking out Wolfram Alpha (http://www70.wolframalpha.com/) and it can do simple optimization problems in math, such as maximize 1

Re: When does the escape character work within raw strings?

2009-05-23 Thread walterbyrd
On May 22, 12:22 pm, "Rhodri James" > How do you know how a string object is going to be treated by any > given function?  Read the Fine Manual for that function. So am I to understand that there is no consistency in string handling throughout the standard modules/objects/methods? Seems to make p

Re: How to pass multiline flag to re.sub without using re.complie.

2009-05-23 Thread Tim Chase
I have a regex that needs multiline flag. Some where I read I can pass multiline flag in regex string itself without using re.compile. If anybody have any idea about how to do that please reply. As detailed at [1], """ (?iLmsux) (One or more letters from the set 'i', 'L', 'm', 's', 'u', 'x'.)

Re: How to pass multiline flag to re.sub without using re.complie.

2009-05-23 Thread MRAB
samba wrote: I have a regex that needs multiline flag. Some where I read I can pass multiline flag in regex string itself without using re.compile. If anybody have any idea about how to do that please reply. Include "(?m)" in the regular expression for multiline matching. It's best to put it a

Re: need a help!

2009-05-23 Thread Dave Angel
Minh Doan wrote: Hi, I'm a newbie to python. I am having stuck with the following problem. I want to download the info(price) from fromcity to tocity at a certain time from kayak.com website. If we do it manually, we can go to the website, choose the appropriate info we want to get and press SEA

Re: Problems with sys.stout.flush()

2009-05-23 Thread Carl Banks
On May 23, 8:20 am, Dave Angel wrote: > Incidentally, Carl's other suggestion, that you use a new variable > instead of overwriting 'char', is a red herring. Yeah, I dropped the ball on this one, I misread his code as being in a loop instead of being called repeatedly. And after criticizing him

Re: need a help!

2009-05-23 Thread Esmail
Minh Doan wrote: Hi, I'm a newbie to python. I am having stuck with the following problem. I want to download the info(price) from fromcity to tocity at a certain time from kayak.com website. If we do it manually, we can go to the website, choose the appropriate info we wa

Re: need a help!

2009-05-23 Thread Kushal Kumaran
On Sun, May 24, 2009 at 12:25 AM, Minh Doan wrote: > Hi, > > I'm a newbie to python. I am having stuck with the following problem. I want > to download the info(price) from fromcity to tocity at a certain time from > kayak.com website. If we do it manually, we can go to the website, choose > the a

need a help!

2009-05-23 Thread Minh Doan
Hi, I'm a newbie to python. I am having stuck with the following problem. I want to download the info(price) from fromcity to tocity at a certain time from kayak.com website. If we do it manually, we can go to the website, choose the appropriate info we want to get and press SEARCH. How can i do i

How to pass multiline flag to re.sub without using re.complie.

2009-05-23 Thread samba
I have a regex that needs multiline flag. Some where I read I can pass multiline flag in regex string itself without using re.compile. If anybody have any idea about how to do that please reply. -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Dave Angel
Vincent Davis wrote: Thank you that makes sense to me. Much more clear then the tutorial, I think so anyway. If you are learning about classes that you kinda expect MyClass to have counter in it. I might be nice to show that x.counter = 1 creates an instance that would look like (is this correct?

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Thanks for all the help guys. I got it to work correctly with this class progress: def __init__(self): self.already = 0 def progressbar(self, number, total, char): percentage = int(100 - round(number*100.0/total)) if percentage > 0: xchar = char * (perc

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Dave Angel
Vincent Davis wrote: Section 9.3.3 says that given, class MyClass: """A simple example class""" i = 12345 def f(self): return 'hello world' and x = MyClass() then this x.counter = 1 while x.counter < 10: x.counter = x.counter * 2 print(x.counter) del x.counter will prin

Re: Problems with sys.stout.flush()

2009-05-23 Thread Steven D'Aprano
On Sun, 24 May 2009 00:44:21 +1000, Joel Ross wrote: > Still having the same problem if I pass it 1000 lines it will printout > 1000 asterisks when I say lines I mean the argument for the > progress() function. I only want to printout 100 asterisks no matter how > many lines I pass to the progres

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Benjamin Kaplan
On Sat, May 23, 2009 at 10:46 AM, Vincent Davis wrote: > Thank you that makes sense to me. Much more clear then the tutorial, I > think so anyway. If you are learning about classes that you kinda expect > MyClass to have counter in it. I might be nice to show that x.counter = 1 > creates an instan

Re: from __future__ import absolute_import issue

2009-05-23 Thread LittleGrasshopper
On May 22, 12:42 am, "Gabriel Genellina" wrote: > En Wed, 20 May 2009 20:18:02 -0300, LittleGrasshopper   > escribió: > > > New to the group, this is my first post... > > > It appears that either absolute imports (or my brain) aren't working. > > Given a module string.py which is in the same dire

Re: Problems with sys.stout.flush()

2009-05-23 Thread Dave Angel
Joel Ross wrote: Carl Banks wrote: On May 23, 2:20 am, Joel Ross wrote: Carl Banks wrote: On May 22, 10:33 pm, Joel Ross wrote: Hi all, I'm using python 2.5 and trying to flush the sys.stout buffer with sys.stout.flush(), but doesn't seem to work. Each time a line is printed it appends

Re: Problems with sys.stout.flush()

2009-05-23 Thread Peter Otten
Joel Ross wrote: > class progress: > > def progressbar(self, number, total, char): > > percentage = float(number*100)/total > percentage = int(round(percentage)) > percentage = int(100 - percentage) > self.f=sys.stdout > if percentage > 0: >

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Michiel Overtoom
Vincent writes: > you kinda expect MyClass to have counter in it. Yeah, that makes sense. These instance variables are often initialized in the __init__ method: class Counter(object): def __init__(self,initialvalue): self.value=initialvalue def inc(self): self.value+

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Carl Banks wrote: On May 23, 3:49 am, Joel Ross wrote: def progressbar(self, number, total, char): percentage = float(number*100)/total percentage = int(round(percentage)) percentage = int(100 - percentage) self.f=sys.stdout if percentage > 0:

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Vincent Davis
Thank you that makes sense to me. Much more clear then the tutorial, I think so anyway. If you are learning about classes that you kinda expect MyClass to have counter in it. I might be nice to show that x.counter = 1 creates an instance that would look like (is this correct?) class MyClass: "

Re: html ui + py background? any tut?

2009-05-23 Thread Stefaan Himpe
Or maybe you are looking for something like nufox? http://nufox.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Benjamin Kaplan
On Sat, May 23, 2009 at 9:13 AM, Vincent Davis wrote: > let me add that I see that this could be right if x.counter = 1 and > counter need not have anything to do with MyClass but this could be more > clear. > Thanks > Vincent Davis > 720-301-3003 > > > On Sat, May 23, 2009 at 7:08 AM, Vincent Dav

Python -> R?

2009-05-23 Thread Esmail
Hello! Anyone using Python scripts and accessing some of R's functionality? If so, what are you using? I have read about RPy, is that a good solution? Are there others that can be recommended or are preferred? I would prefer to code in Python instead of R :-) Thanks, Esmail -- http://mail.pyth

Re: html ui + py background? any tut?

2009-05-23 Thread Stefaan Himpe
Perhaps you want to investigate pyjamas[1] and pyjamas-desktop[2] [1] http://pyjs.org/ [2] http://pyjd.sourceforge.net/ Best regards, Stefaan. -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimizing math functions

2009-05-23 Thread Esmail
Steven D'Aprano wrote: On Sat, 23 May 2009 09:22:59 -0400, Esmail wrote: Hello all, I would like to maximize or minimize a given math function over a specific set of values, in Python preferably. ... What it apparently can't do is for maximize (or minimize) functions that contain two variabl

Re: Optimizing math functions

2009-05-23 Thread Steven D'Aprano
On Sat, 23 May 2009 09:22:59 -0400, Esmail wrote: > Hello all, > > I would like to maximize or minimize a given math function over a > specific set of values, in Python preferably. ... > What it apparently can't do is for maximize (or minimize) functions that > contain two variables, x and y, or

Re: Replacing module with a stub for unit testing

2009-05-23 Thread Ben Finney
pigmart...@gmail.com writes: > > import ExpensiveModuleStub > sys.modules['ExpensiveModule'] = ExpensiveModuleStub # Doesn't > work > > But, import statements in the IntermediateModule still access the real > ExpensiveModule, not the stub. > > The examples I can find of creating and usi

Re: Replacing module with a stub for unit testing

2009-05-23 Thread Steven D'Aprano
On Sat, 23 May 2009 06:00:15 -0700, pigmartian wrote: > Hi, > > I'm working on a unit test framework for a module. The module I'm > testing indirectly calls another module which is expensive to access --- > CDLLs whose functions access a database. ... > The examples I can find of creating and us

Optimizing math functions

2009-05-23 Thread Esmail
Hello all, I would like to maximize or minimize a given math function over a specific set of values, in Python preferably. I was checking out Wolfram Alpha (http://www70.wolframalpha.com/) and it can do simple optimization problems in math, such as maximize 15*x - x**2 over 0 to 15 (ht

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Vincent Davis
let me add that I see that this could be right if x.counter = 1 and counter need not have anything to do with MyClass but this could be more clear. Thanks Vincent Davis 720-301-3003 On Sat, May 23, 2009 at 7:08 AM, Vincent Davis wrote: > Section 9.3.3 says that given, > class MyClass: > """A

error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Vincent Davis
Section 9.3.3 says that given, class MyClass: """A simple example class""" i = 12345 def f(self): return 'hello world' and x = MyClass() then this x.counter = 1 while x.counter < 10: x.counter = x.counter * 2 print(x.counter) del x.counter will print 16 link, http://docs

Replacing module with a stub for unit testing

2009-05-23 Thread pigmartian
Hi, I'm working on a unit test framework for a module. The module I'm testing indirectly calls another module which is expensive to access --- CDLLs whose functions access a database. test_MyModule --->MyModule--->IntermediateModule--- >ExpensiveModule I want to create a stub of ExpensiveMo

Re: html ui + py background? any tut?

2009-05-23 Thread Дамјан Георгиевски
> I have read for many times that the modern appliaction (not a web one, > but desktop on) uses html + js for its UI, and python code is for the > background work > but I have never found event a simple (yet completed) article on how > to develop such a thing from scrach in these advocacy thing.

PureData py/pyExt into standalone python

2009-05-23 Thread responsible7
Hi guys, Short version: I've written some python classes for py/pyExt extensions for the "dataflow" graphical programming environment PureData. Here's an example PureData screenshot for clarity: see: http://i40.tinypic.com/2rrx6gy.jpg My classes talk to eachother via the PureData system

Re: Representing a Tree in Python

2009-05-23 Thread Albert van der Horst
In article <43289c33-04b9-4cbc-9823-d8a4ee86d...@y33g2000prg.googlegroups.com>, godshorse wrote: >On May 13, 11:54=A0am, CTO wrote: >> On May 13, 12:10=A0am, godshorse wrote: >> >> > Hello, >> >> > I want to find out the shortest path tree from a root to several nodes >> > in a graph data struc

Re: Problems with sys.stout.flush()

2009-05-23 Thread Carl Banks
On May 23, 3:49 am, Joel Ross wrote: >      def progressbar(self, number, total,  char): > >          percentage = float(number*100)/total >          percentage = int(round(percentage)) >          percentage = int(100 - percentage) >          self.f=sys.stdout >          if percentage > 0: >      

Abstract Classes

2009-05-23 Thread Tim Cook
I am implementing a set of specifications that were designed to be OO language neutral. Several classes are specified as being abstract; so therefore there should be no instances of them, correct? However in the classes that are subclasses what is the correct way in Python to implement them? I am

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Carl Banks wrote: On May 23, 2:20 am, Joel Ross wrote: Carl Banks wrote: On May 22, 10:33 pm, Joel Ross wrote: Hi all, I'm using python 2.5 and trying to flush the sys.stout buffer with sys.stout.flush(), but doesn't seem to work. Each time a line is printed it appends the one before it I

Re: Problems with sys.stout.flush()

2009-05-23 Thread Mohammed Mediani
Hi all, Is anyone aware of a 3-d plotting tool for simple mathematical functions. It seems that all the tools available have their problems with new versions. None of matplotlib, nor PyX, nor mat3d, seems to work for 3d anymore. Any suggestions??? Thanks -- http://mail.python.org/mailman/listi

Re: Problems with sys.stout.flush()

2009-05-23 Thread Carl Banks
On May 23, 2:20 am, Joel Ross wrote: > Carl Banks wrote: > > On May 22, 10:33 pm, Joel Ross wrote: > >> Hi all, > > >> I'm using python 2.5 and trying to flush the sys.stout buffer with > >> sys.stout.flush(), but doesn't seem to work. Each time a line is printed > >>    it appends the one before

Re: html ui + py background? any tut?

2009-05-23 Thread David Lyon
Hi, I don't know any tutorial either... At work, we have made gui apps using wxpython to make the gui... wxpython has html viewer component... you can use Cheetah or another template engine to make the html... It's pretty easy and effective... David On Sat, 23 May 2009 15:48:38 +0800, oyst

Re: Problems with sys.stout.flush()

2009-05-23 Thread Joel Ross
Carl Banks wrote: On May 22, 10:33 pm, Joel Ross wrote: Hi all, I'm using python 2.5 and trying to flush the sys.stout buffer with sys.stout.flush(), but doesn't seem to work. Each time a line is printed it appends the one before it I need to clear the output and write a new output without

Re: Ambiguous locale.strxfrm

2009-05-23 Thread Tuomas Vesterinen
Thanks. Bug report done, issue 6093. Tuomas Vesterinen Gabriel Genellina wrote: En Fri, 22 May 2009 06:32:40 -0300, Tuomas Vesterinen escribió: This was fixed once in Python 2.5, but in Python 3.0 the bug celebrates its comeback. The tail of the strxfrm result is ambiguous. Python 3.0.1

html ui + py background? any tut?

2009-05-23 Thread oyster
I have read for many times that the modern appliaction (not a web one, but desktop on) uses html + js for its UI, and python code is for the background work but I have never found event a simple (yet completed) article on how to develop such a thing from scrach in these advocacy thing. Can anyone