[Tutor] Finding the minimum value in a multidimensional array

2007-03-13 Thread Geoframer
Hey everyone, I've been trying to locate a way to find the location of the minimum value in an n*n array. For instance suppose we have a 10x10 array. In [1]: import numpy In [2]: a = numpy.zeros((10,10)) In [3]: a Out[3]: array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0.

[Tutor] HTTP file download

2007-03-13 Thread ronaldo
Hello all, How can I download a file using HTTP? For example: There is a file at: http://www.somesite.com/file. I need to get this file using HTTP from a python script. I'm not sure but I think httplib could be used to do that. Can anyone confirm that? or Can anyone suggest me something else? Th

[Tutor] Squlite3 problem

2007-03-13 Thread Jim Roush
I'm geting the following error message and I'm stumped Traceback (most recent call last): File "C:\markets\source\QuantScan\QuantScan4_3.py", line 1362, in db.close() sqlite3.OperationalError: Unable to close due to unfinalised statements Here 's the relevant code db = sqlite.conn

Re: [Tutor] Squlite3 problem

2007-03-13 Thread Jason Massey
I found a similar discussion on the pysqlite mailing list ( http://lists.initd.org/pipermail/pysqlite/2005-August/000127.html) Try committing your changes and then closing your cursor. db.commit() cur.close() db.close() On 3/13/07, Jim Roush <[EMAIL PROTECTED]> wrote: I'm geting the followin

Re: [Tutor] HTTP file download

2007-03-13 Thread Jean-Philippe Durand
Hello Ronaldo, Try this : import urllib mysock = urllib.urlopen("http://www.somesite.com/file";) htmlSource = mysock.read() mysock.close() print htmlSource Regards. Jean-Philippe DURAND 2007/3/13, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: Hello all, How can I download a file using HTTP? For ex

Re: [Tutor] number generator

2007-03-13 Thread Dick Moores
At 02:52 AM 3/13/2007, Duncan Booth wrote: >Dick Moores <[EMAIL PROTECTED]> wrote: > > > But let's say there is one more constraint--that for each n of the N > > positive integers, there must be an equal chance for n to be any of > > the integers between 1 and M-N+1, inclusive. Thus for M == 50 and

Re: [Tutor] number generator

2007-03-13 Thread Dick Moores
So sorry. I meant this for the python list. Dick Moores At 05:49 AM 3/13/2007, Dick Moores wrote: >At 02:52 AM 3/13/2007, Duncan Booth wrote: > >Dick Moores <[EMAIL PROTECTED]> wrote: > > > > > But let's say there is one more constraint--that for each n of the N > > > positive integers, there mus

Re: [Tutor] Finding the minimum value in a multidimensional array

2007-03-13 Thread Eike Welk
On Tuesday 13 March 2007 11:57, Geoframer wrote: > Hey everyone, > > I've been trying to locate a way to find the location of the > minimum value in an n*n array. The 'argmin' function is probably what you are looking for. See the examples at: http://www.scipy.org/Numpy_Example_List Regards Eike

Re: [Tutor] Finding the minimum value in a multidimensional array

2007-03-13 Thread Geoframer
I don't see a solution here... It is not conclusive on what's the minimum for an array. ln [1]: import numpy In [2]: a = numpy.array([[1,2,3,0],[2,3,4,5],[6,5,4,3],[-1,2,-4,5]]) In [3]: a Out[3]: array([[ 1, 2, 3, 0], [ 2, 3, 4, 5], [ 6, 5, 4, 3], [-1, 2, -4, 5]]) I

Re: [Tutor] Finding the minimum value in a multidimensional array

2007-03-13 Thread Jerry Hill
On 3/13/07, Geoframer <[EMAIL PROTECTED]> wrote: > I don't see a solution here... It is not conclusive on what's the minimum > for an array. > > ln [1]: import numpy > In [2]: a = > numpy.array([[1,2,3,0],[2,3,4,5],[6,5,4,3],[-1,2,-4,5]]) Well, what exactly is it that you'd like the answer to be?

[Tutor] Quicktime & Python

2007-03-13 Thread Miguel Oliveira, Jr.
Hello, Just wondering: is there a way to play quicktime .mov files from python? I am trying to run an experiment and would like to have Python to play the .mov files I have in a given sequence (or in random), in full screen and to record a log of the files that were played, the order and t

[Tutor] Numpy

2007-03-13 Thread Miguel Oliveira, Jr.
Hello, I've just intalled [manually] numpy into a Mac Intel OS 10.4. I'm running Python version 2.5. Whenever I import numpy, I get the following message: Running from numpy source directory Does anyone know if this is normal? In Python 2.4, no such message pops up when numpy is imported.

Re: [Tutor] Quicktime & Python

2007-03-13 Thread Hugo González Monteverde
Miguel Oliveira, Jr. wrote: > Hello, > > Just wondering: is there a way to play quicktime .mov files from > python? I am trying to run an experiment and would like to have > Python to play the .mov files I have in a given sequence (or in > random), in full screen and to record a log of the f

Re: [Tutor] trouble with function-- trying to check differences btwn 2 strings

2007-03-13 Thread Terry Carroll
On Tue, 6 Mar 2007, Alan Gauld wrote: > But I've been up since 4:30am and am too tired to try > figuring it out just now, so maybe someone else will > explain! :-) > > >>> for c in 'abcd': > ...print (c == c in 'crab') > ... > True > True > True > False Trying to understand that, I tried t

Re: [Tutor] Roman to digital (pseudocode)

2007-03-13 Thread Bob Gailer
Deep breath and big step back. The problem is not just how to code this in Python, but how to parse a language (in this case Roman Numbers). I have studied formal language theory but am not an expert. So here's my take on an algorithm that would save a lot of stress. Create a dictionary w

Re: [Tutor] Roman to digital (pseudocode)

2007-03-13 Thread Clay Wiedemann
I am new to python and programming, so not sure if I should weigh in here. Nonetheless . . . Creating a dictionary seems fair, but I wonder about using pairs rather than single letters. Roman numerals are constructed from strict rules other than the allowable letter set -- here is the relevant wik

[Tutor] Lexicographic ordering (or something simpler)

2007-03-13 Thread Matt Williams
Dear All, I'm trying to write something to calculate rule priorities, based on their provenance (ultimately I'm after a lexicographic ordering) I have a set of terms (the provenances) I'm try to sort. I've done it by associating each possible set of terms with a dictionary, and then using the

Re: [Tutor] Roman to digital (pseudocode)

2007-03-13 Thread Kent Johnson
Alan Gilfoy wrote: > This, I heard, is more difficult than digital-to-Roman, since you have > to "read" the subtractive cases, with a smaller numeral placed before > a larger numeral, without simply adding all the numerals' values up > > I'm going to use a raw_input prompt to ask the user whic

Re: [Tutor] Roman to digital (pseudocode)

2007-03-13 Thread Kent Johnson
Bob Gailer wrote: > Deep breath and big step back. > > The problem is not just how to code this in Python, but how to parse a > language (in this case Roman Numbers). > > I have studied formal language theory but am not an expert. So here's my > take on an algorithm that would save a lot o

Re: [Tutor] Lexicographic ordering (or something simpler)

2007-03-13 Thread Kent Johnson
Matt Williams wrote: > Dear All, > > I'm trying to write something to calculate rule priorities, based on > their provenance (ultimately I'm after a lexicographic ordering) I don't understand your problem description at all but maybe this will help. If you sort a list of lists or a list of tupl

Re: [Tutor] HTTP file download

2007-03-13 Thread Tony Cappellini
How do you handle a binary file? Message: 4 Date: Tue, 13 Mar 2007 13:23:44 +0100 From: "Jean-Philippe Durand" <[EMAIL PROTECTED]> Subject: Re: [Tutor] HTTP file download To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> Cc: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plai

[Tutor] declaring decaration on ul list

2007-03-13 Thread Kirk Bailey
It just occurred to me that when my wiki does a backsearch it is useful to list the results with a * for decorating the unordered list results, so I can mousecopy it to update the category(foo) page, /the normal bullet is mousecopied as a poundsign (#}. How does one specify what to render as a

Re: [Tutor] trouble with function-- trying to check

2007-03-13 Thread Isaac
a, b, c are all in crab but d is not. >>> for c in 'abcd': ...print (c == c in 'crab') ... True True True False Message: 5 Date: Tue, 13 Mar 2007 13:01:48 -0700 (PDT) From: Terry Carroll <[EMAIL PROTECTED]> Subject: Re: [Tutor] trouble with function-- trying to check differenc

Re: [Tutor] trouble with function-- trying to check

2007-03-13 Thread Isaac
a, b, c, or d is a type('str') not boolean which is what (c in "crab") is. The [in] operator takes presedence, the first 3 times (c in "crab") returns true and the last returns false; but the strings a, b, c, or d do not == true or false - therefore the test (c == (c in "crab")) always returns fal