Re: Eureka moments in Python

2007-03-13 Thread Brett g Porter
Dustan wrote: > On Mar 13, 10:05 am, Brett g Porter <[EMAIL PROTECTED]> wrote: >> Steven D'Aprano wrote: >>> I'd be interested in hearing people's stories of Eureka moments in Python, >>> moments where you suddenly realise that some task which seemed like it >>> would be hard work was easy with Pyt

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Diez B. Roggisch
> It's an AJAX-site. You have to carefully analyze it and see what > actually happens in the javascript, then use that. Maybe something like > the http header plugin for firefox helps you there. ups, obviously I wasn't looking enough at the site. Sorry for the confusion. Still, some pages are

Re: Iterating across a filtered list

2007-03-13 Thread Arnaud Delobelle
On Mar 13, 9:31 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 13 Mar 2007 17:19:53 -0300, Arnaud Delobelle > <[EMAIL PROTECTED]> escribió: > > > On Mar 13, 7:36 pm, Paul Rubin wrote: > > >> The re library caches the compiled regexp, I think. > > > That wo

Re: ANN: ActivePython 2.5.0.0 is now available

2007-03-13 Thread Ben Finney
"Wensui Liu" <[EMAIL PROTECTED]> writes: > Is [ActivePython] free of charge? Yes. The only cost is to learn how to quote messages considerately. (Please quote in sequence with what you're responding to, and trim all the lines from the quoted message that aren't directly relevant to your reply.)

Re: Parsing Indented Text (like parsing Python)

2007-03-13 Thread alisonken1
On Mar 11, 2:34 am, "Mike Schinkel" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm relatively new to Python but have lots of prior programming experience > as a developer, instructor, and author (ASP/VBScript/SQL Server and > Clipper.) > > -- > -Mike > Schinkelhttp://www.mikeschinkel.com/blogs/http:/

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > Still, some pages are AJAX, you won't be able to scrape them easily > without analyzing the JS code. Sooner or later it would be great to have a JS interpreter written in Python for this purpose. It would do all the same operations on an HTML/XML D

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Diez B. Roggisch
Paul Rubin schrieb: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> Still, some pages are AJAX, you won't be able to scrape them easily >> without analyzing the JS code. > > Sooner or later it would be great to have a JS interpreter written in > Python for this purpose. It would do all the sa

Iterating across a filtered list

2007-03-13 Thread Łukasz Ligowski
Hi, On Tuesday 13 of March 2007 22:16:32 Arnaud Delobelle wrote: > for x in L: > if g(x): > do stuff with f(x) for x in itertools.ifilterfalse(g, L): do stuff Maybe this would be even better? L -- http://mail.python.org/mailman/listinfo/python-list

Problem I have with a while loop/boolean/or

2007-03-13 Thread [EMAIL PROTECTED]
Hi all. I have a problem with some code :( --- hint = raw_input("\nAre you stuck? y/n: ") hint = hint.lower() while (hint != 'n') or (hint != 'y'): hint = raw_input("Please specify a valid choice: ") - so everytime I run the program, and

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > Nice idea, but not really helpful in the end. Besides the rather nasty > parts of the DOMs that make JS programming the PITA it is, I think the > whole event-based stuff makes this basically impossible. Obviously the Python interface would need ways

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > while (hint != 'n') or (hint != 'y'): > hint = raw_input("Please specify a valid choice: ") > > - > > so everytime I run the program, and enter my choice as y or n, I'm > told to 'Please Specify a va

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Larry Bates
[EMAIL PROTECTED] wrote: > Hi all. > > I have a problem with some code :( > > --- > > hint = raw_input("\nAre you stuck? y/n: ") > hint = hint.lower() > > while (hint != 'n') or (hint != 'y'): > hint = raw_input("Please specify a valid choice: ") > > ---

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread [EMAIL PROTECTED]
On Mar 13, 10:43 pm, Paul Rubin wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > while (hint != 'n') or (hint != 'y'): > > hint = raw_input("Please specify a valid choice: ") > > > - > > > so everytime I run the

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread [EMAIL PROTECTED]
On Mar 13, 10:50 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi all. > > > I have a problem with some code :( > > > --- > > > hint = raw_input("\nAre you stuck? y/n: ") > > hint = hint.lower() > > > while (hint != 'n') or (hint != 'y'): > > hint = raw_input

Re: Iterating across a filtered list

2007-03-13 Thread Gabriel Genellina
En Tue, 13 Mar 2007 19:12:12 -0300, Arnaud Delobelle <[EMAIL PROTECTED]> escribió: >> py> import re >> py> x = re.compile("ijk") >> py> y = re.compile("ijk") >> py> x is y >> True >> >> Both, separate calls, returned identical results. You can show the >> cache: > > OK I didn't realise this.

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread John McMonagle
[EMAIL PROTECTED] wrote: > Hi all. > > I have a problem with some code :( > > --- > > hint = raw_input("\nAre you stuck? y/n: ") > hint = hint.lower() > > while (hint != 'n') or (hint != 'y'): > hint = raw_input("Please specify a valid choice: ") > > ---

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Diez B. Roggisch
Paul Rubin schrieb: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> Nice idea, but not really helpful in the end. Besides the rather nasty >> parts of the DOMs that make JS programming the PITA it is, I think the >> whole event-based stuff makes this basically impossible. > > Obviously the Pyt

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > Obviously this wouldn't really help, as you can't predict what a > website actually wants which events, in possibly which > order. Especially if the site does not _want_ to be scrapable- think > of a simple "click on the images in the order of the nu

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread John Nagle
[EMAIL PROTECTED] wrote: > How extract the visible numerical data from this Microsoft financial > web site? > > http://tinyurl.com/yw2w4h > > If you simply download the HTML file you'll see the data is *not* > embedded in it but loaded from some other file. > > Surely if I can see the data in my

Problem in importing fipy

2007-03-13 Thread [EMAIL PROTECTED]
Hi, I am using fipy for solving an ODE on python. I am getting an error in the line: "from fipy.meshes.grid1D import Grid1D", which says: ImportError: No module named fipy.meshes.grid1D Importing only fipy also gives a similar error. I have Python2.4.4, numpy, matplotlib and fipy installed on my

Re: Problem in importing fipy

2007-03-13 Thread Larry Bates
[EMAIL PROTECTED] wrote: > Hi, > > I am using fipy for solving an ODE on python. > > I am getting an error in the line: "from fipy.meshes.grid1D import > Grid1D", which says: > ImportError: No module named fipy.meshes.grid1D > Importing only fipy also gives a similar error. > > I have Python2.4.

Re: struct.pack oddity

2007-03-13 Thread Steve Holden
Dave Opstad wrote: > In article <[EMAIL PROTECTED]>, > "Erik Johnson" <[EMAIL PROTECTED]> wrote: > >> Barring anyone else disagreeing with classifying it as a bug, I would >> suggest reporting it. Proper procedure for reporting a bug appears to be >> covered in section B of the Python Library

Re: number generator

2007-03-13 Thread greg
Gabriel Genellina wrote: > The 5th number is not "random". More precisely, the fifth number is not *independent* of the others. You can't have five independent random numbers that sum to 50; only four independent numbers plus a dependent one. -- Greg -- http://mail.python.org/mailman/listinfo/py

Re: Tools for GUI/graphics

2007-03-13 Thread Erik Johnson
> You can use ReportLab Graphics to generate the > graphs as .JPG files and display them in a > browser window with simple HTML. That is one option. As best as I recall, CherryPy is a simple but fully functional web framework. If your primary focus is programmatically generating graphs from d

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Steve Holden
Paul Rubin wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> Obviously this wouldn't really help, as you can't predict what a >> website actually wants which events, in possibly which >> order. Especially if the site does not _want_ to be scrapable- think >> of a simple "click on the image

Re: number generator

2007-03-13 Thread Dick Moores
At 05:47 PM 3/10/2007, Paul Rubin wrote: >The fencepost method still seems to be simplest: > > t = sorted(random.sample(xrange(1,50), 4)) > print [(j-i) for i,j in zip([0]+t, t+[50])] = M = 50 N = 4 def sumRndIntRubin(M, N): import random t = sort

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > I especially like the rems and conditions they ask you to acknowledge > if you want to sign up as a worker: >http://www.captchasolver.com/join/worker# Heh, cute, I guess you have to solve a different type of puzzle to read them. I'm surprised anyone

RE: list of dictionary in embedded Python

2007-03-13 Thread ZiZi Zhao
You are right! I added Py_INCREF(pDict); right behind pDict = PyDict_New(); it seems to work correctly. thanks, zz -Original Message- From: [EMAIL PROTECTED] on behalf of Gabriel Genellina Sent: Thu 3/8/2007 7:15 PM To: python-list@python.org Subject: Re: list of dictionary in embedde

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Bart Willems
John McMonagle wrote: > Try it a different way: > > while True: > hint = raw_input("\nAre you stuck? y/n: ") > hint = hint.lower() > if hint != 'y' and hint != 'n': > print "Please answer y or n" > continue > else: > break > if hint == 'y': > do_your_hin

Re: number generator

2007-03-13 Thread Steven D'Aprano
On Tue, 13 Mar 2007 17:53:41 -0700, Dick Moores wrote: > At 05:47 PM 3/10/2007, Paul Rubin wrote: > >>The fencepost method still seems to be simplest: >> >> t = sorted(random.sample(xrange(1,50), 4)) >> print [(j-i) for i,j in zip([0]+t, t+[50])] > > = > M

Re: number generator

2007-03-13 Thread Paul Rubin
Dick Moores <[EMAIL PROTECTED]> writes: > I understand what zip() and random.sample() are doing, and the above > helps me get inside the fencepost method, but I don't understand WHY > it works, or how in the world anyone could have devised it. It is > truly magical to me! It's Gerald Flanagan's te

Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread vj
I've tried to post this to the numpy google group but it seems to be down. My migration seems to be going well. I currently have one issue with using scipy_base.insert. >>> a = zeros(5) >>> mask = zeros(5) >>> mask[1] = 1 >>> c = zeros(1) >>> c[0] = 100 >>> numpy.insert(a, mask, c) array([ 100.,

how to detect change of list of instances

2007-03-13 Thread manstey
how do I detect a change in a list of class instances? from copy import deepcopy class CaListOfObj(list): """ subclass of list """ def __init__(self, *args, **kwargs): list.__init__(self, *args, **kwargs) class CaClass(object): pass class CaData(object): pass myclass=Ca

Re: number generator

2007-03-13 Thread Steven D'Aprano
On Tue, 13 Mar 2007 08:20:49 +0200, Hendrik van Rooyen wrote: > Is it possible to devise a test that can distinguish between sets > of: > > - five random numbers that add to 50, and > - four random numbers and a fudge number that add to 50? > > My stats are way too small and rusty to attempt to

Re: Eureka moments in Python

2007-03-13 Thread Ben Finney
"Steven D'Aprano" <[EMAIL PROTECTED]> writes: > I'd be interested in hearing people's stories of Eureka moments in > Python, moments where you suddenly realise that some task which > seemed like it would be hard work was easy with Python. I don't recall the exact context, but Python was the langu

Re: number generator

2007-03-13 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Me too. Although Alex Martelli's algorithm: > > map([random.randrange(5) for i in xrange(45)].count, xrange(5)) > > (each value needs adjusting up by one) really boggles my brain. I'm going > to have to think about that. Heh, that is woefully ineffic

Re: number generator

2007-03-13 Thread Duncan Smith
Hendrik van Rooyen wrote: > "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote: > > >>Paul Rubin wrote: >> >>> The fencepost method still seems to be simplest: >>> >>> t = sorted(random.sample(xrange(1,50), 4)) >>> print [(j-i) for i,j in zip([0]+t, t+[50])] >> >>Mmm, nice. >> >>Here is anothe

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread Robert Kern
vj wrote: > I've tried to post this to the numpy google group but it seems to be > down. It is just a redirection to the numpy-discussion@scipy.org list. If you just tried in the past hour or so, I've discovered that our DNS appears to be down right now. > My migration seems to be going well. I c

Re: how to detect change of list of instances

2007-03-13 Thread Steven D'Aprano
On Tue, 13 Mar 2007 18:23:24 -0700, manstey wrote: > how do I detect a change in a list of class instances? > > from copy import deepcopy > > class CaListOfObj(list): > """ subclass of list """ > def __init__(self, *args, **kwargs): > list.__init__(self, *args, **kwargs) > > cla

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread hg
[EMAIL PROTECTED] wrote: > Hi all. > > I have a problem with some code :( > > --- > > hint = raw_input("\nAre you stuck? y/n: ") > hint = hint.lower() > > while (hint != 'n') or (hint != 'y'): > hint = raw_input("Please specify a valid choice: ") > > --

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread hg
hg wrote: > [EMAIL PROTECTED] wrote: > >> Hi all. >> >> I have a problem with some code :( >> >> --- >> >> hint = raw_input("\nAre you stuck? y/n: ") >> hint = hint.lower() >> >> while (hint != 'n') or (hint != 'y'): >> hint = raw_input("Please specify a valid choice: ") >> >> --

Re: number generator

2007-03-13 Thread Duncan Smith
greg wrote: > Gabriel Genellina wrote: > >> The 5th number is not "random". > > > More precisely, the fifth number is not *independent* > of the others. You can't have five independent random > numbers that sum to 50; only four independent numbers > plus a dependent one. > > -- > Greg In the

Re: number generator

2007-03-13 Thread Dick Moores
At 06:20 PM 3/13/2007, Paul Rubin wrote: >Dick Moores <[EMAIL PROTECTED]> writes: > > I understand what zip() and random.sample() are doing, and the above > > helps me get inside the fencepost method, but I don't understand WHY > > it works, or how in the world anyone could have devised it. It is >

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread vj
> It is just a redirection to the [EMAIL PROTECTED] list. If you just > tried in the past hour or so, I've discovered that our DNS appears to be down > right now. I tried registering the twice the last couple of days and never got an email back. > No, that's not what insert() does. See the docstr

Re: Eureka moments in Python

2007-03-13 Thread Jeff McNeil
Bit of a newbie on this list, but here goes... Web Services. The company I'm working for has been pretty big into the WS-* specifications and the Microsoft .Net WCF components for our business systems. I'm one of three Unix guys that code the products while we've a larger team of Windows develop

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread Robert Kern
vj wrote: >> It is just a redirection to the [EMAIL PROTECTED] list. If you just >> tried in the past hour or so, I've discovered that our DNS appears to be down >> right now. > > I tried registering the twice the last couple of days and never got an > email back. Hmm. Odd. I just tried to regist

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread vj
> Note that the mask needs to be a bool array. >>> mask = zeros(5) >>> mask = zeros(5, numpy.int8) >>> mask[1] = True >>> mask[2] = True >>> a = zeros(5) >>> a[mask] = [100, 200] >>> a array([ 100., 100.,0.,0.,0.]) I found this strange. It should just give an error if you try to use

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-13 Thread Robert Kern
vj wrote: >> Note that the mask needs to be a bool array. > mask = zeros(5) mask = zeros(5, numpy.int8) mask[1] = True mask[2] = True a = zeros(5) a[mask] = [100, 200] a > array([ 100., 100.,0.,0.,0.]) > > I found this strange. It should just give a

Re: number generator

2007-03-13 Thread [EMAIL PROTECTED]
It should be possible to enumerate all sets of five numbers which sum to 50 and randomly select one of them. Cheers, -T -- http://mail.python.org/mailman/listinfo/python-list

python/C++ wrapper

2007-03-13 Thread Frank
Hi, is there anyone here that calls C++ programs from python via swig? It seems that there are a lot of different ways to do that. For me it would be important that the original c++ code (which is available) does not need to be changed and the whole compilation process (swig - python g++e

Re: help developing an editor to view openoffice files.

2007-03-13 Thread krishnakant Mane
hello, well what I exactly need to do is firstly have a way to read .odt and .ods files. I have a lot of information in open office format which I need to access. The most important thing is that I completely want to avoid the use of microsoft office. so I need to firstly get access to open office

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Scott David Daniels
Bart Willems wrote: > ... > I always try to stay away from 'negative' operators if possible, to > improve readability: > > while True: >hint = raw_input('\nAre you stuck? y/n: ').lower() >if hint = 'y' or hint = 'n': > break >else: > print 'Please answer yes or no' And if

Re: help developing an editor to view openoffice files.

2007-03-13 Thread Paul Hummer
krishnakant Mane wrote: > hello, > well what I exactly need to do is firstly have a way to read .odt and > .ods files. > I have a lot of information in open office format which I need to access. > The most important thing is that I completely want to avoid the use of > microsoft office. > so I need

Re: python/C++ wrapper

2007-03-13 Thread Roman Yakovenko
On 13 Mar 2007 21:55:55 -0700, Frank <[EMAIL PROTECTED]> wrote: > > Hi, > > is there anyone here that calls C++ programs from python via swig? It > seems that there are a lot of different ways to do that. For me it > would be important that the original c++ code (which is available) > does not need

Re: Twelve Proofs that Muhammad is a True Prophet

2007-03-13 Thread Michael Bentley
On Mar 14, 2007, at 12:09 AM, moslim wrote: > My brothers and sisters everywhere! With this essay, I am not singling > out the adherents of Islam - to which I ascribe - but rather I am > writing this essay to every man and woman throughout the whole world. > ... > You know, at first I didn't rea

Re: how to detect change of list of instances

2007-03-13 Thread manstey
Thanks. All I want to know is whether the newlist, as a list of instances, is modified. I thought equality was the way to go, but is there a simpler way? How can I monitor the state of newlist and set a flag if it is changed in anyway? -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-13 Thread Paul Rubin
Paul Rubin writes: > # yield all partitions of n having length k, with many duplications > def _partitions(n,k): > if k==0: return > for i in xrange(1,n-k+1): > for p in partitions(n-i, k-1): > yield (i,)+p Bah, I manag

Re: number generator

2007-03-13 Thread Steven D'Aprano
On Tue, 13 Mar 2007 20:42:17 -0700, [EMAIL PROTECTED] wrote: > It should be possible to enumerate all sets of five numbers which sum > to 50 and randomly select one of them. Of course it's possible. It's also a very inefficient way of doing so. For five numbers between 1 and 50, there are 50**5 =

Re: number generator

2007-03-13 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > It should be possible to enumerate all sets of five numbers which sum > > to 50 and randomly select one of them. > > Of course it's possible. It's also a very inefficient way of doing so. For > five numbers between 1 and 50, there are 50**5 = 312,500

<    1   2