Re: [Tutor] How to make a python binding for a c library?

2008-05-12 Thread Mark Tolonen
"tuyun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi I have a library written in C, I want to make a python binding for it. But I dont know how to get started. Is there any guide or document? Is "Python/C API Reference Manual" the right doc I need to study first? Check out t

[Tutor] a replace function using re module

2008-05-12 Thread Dick Moores
As more practice with the re module I thought I'd make this function, replace2(): def replace2(astr, regex, repl, case=0, count=0):     """     Replace all regex matches in a string with repl.     case=0 is case insensitive.     count=0 means make all possible replacements.     count=n (n > 0) me

[Tutor] How to make a python binding for a c library?

2008-05-12 Thread tuyun
Hi I have a library written in C, I want to make a python binding for it. But I dont know how to get started. Is there any guide or document? Is "Python/C API Reference Manual" the right doc I need to study first? Thanks in advance Twomol ___

[Tutor] pyUSB linux + unknown device

2008-05-12 Thread Downbound
I'm trying to make an interface between my weather station and my linux server however the only output the weather station has is USB. Further, there are only windows drivers for this Honeywell weather station. Thus, I'm trying to use Python and pyUSB to interface. I THINK i've gotten pretty close

Re: [Tutor] Using Python for accurate calculations

2008-05-12 Thread Alan Gauld
"Gloom Demon" <[EMAIL PROTECTED]> wrote I am working on a function which is going to calculate correlation between two given sets of numbers. Example: x=[10.0, 10.8, 11.3, 10.0, 10.1, 11.1, 11.3, 10.2, 13.5, 12.3, 14.5, 11.0, y=[0.70, 0.73, 0.75, 0.70, 0.65, 0.65, 0.70, 0.61, 0.70, 0.63, 0.70

Re: [Tutor] Else Clause In A Loop

2008-05-12 Thread Alan Gauld
"kinuthia muchane" <[EMAIL PROTECTED]> wrote This has served to confuse me more. Would someone please kindly explain how all this fits into the code below which searches (and finds!) for prime numbers... It doesn't find prime numbers very well. It only finds the primes *below* the one enter

Re: [Tutor] how to return an error from a CGI

2008-05-12 Thread Danny Yoo
Hi John, It's been a long time! I believe you may be looking for the Status Code stuff that web servers use to tell browsers that something special is happening. See Section 3.3.1.3 in: http://www.unix.com.ua/orelly/linux/cgi/ch03_03.htm for an example done in Perl; the code should be

Re: [Tutor] Else Clause In A Loop

2008-05-12 Thread kinuthia muchane
On Mon, 2008-05-12 at 14:08 -0400, "Simón A. Ruiz" wrote: > I'll try my hand at this: > > The outside for loop is looking through every number up to the variable > "number". No quarrel here. > > For each of those numbers, it checks to see if any number between 2 and > i is divisible into i. If

Re: [Tutor] Else Clause In A Loop

2008-05-12 Thread Simón A. Ruiz
I'll try my hand at this: The outside for loop is looking through every number up to the variable "number". For each of those numbers, it checks to see if any number between 2 and i is divisible into i. If it finds anything, we know it's not a prime, and so it breaks out of that second loop

[Tutor] how to return an error from a CGI

2008-05-12 Thread Ertl, John C CIV 63134
Classification: UNCLASSIFIED Caveat (s): FOUO All, I have been writing simple cgi scripts for a long time but have never worried about the error codes. Now I have been asked to return a specific error and I have no idea how to do this. I do not even know if I should be returning an HTTP or

Re: [Tutor] Using Python for accurate calculations

2008-05-12 Thread bob gailer
Gloom Demon wrote: Hello I am working on a function which is going to calculate correlation between two given sets of numbers. Example: x=[10.0, 10.8, 11.3, 10.0, 10.1, 11.1, 11.3, 10.2, 13.5, 12.3, 14.5, 11.0, 12.0, 11.8, 13.4, 11.4, 12.0, 15.6, 13.0, 12.1] y=[0.70, 0.73, 0.75, 0.70, 0.65,

[Tutor] Else Clause In A Loop

2008-05-12 Thread kinuthia muchane
Hi, I learnt that a loop can have an else clause. And that this clause executes when the loop TERMINATES. In a while loop when the condition becomes false, and in a for loop when a sequence is exhausted. When I write the following code it seems to work: for n in [1,2,3,4,5]: print 'we are

Re: [Tutor] Using Python for accurate calculations

2008-05-12 Thread bob gailer
Gloom Demon wrote: Hello I am working on a function which is going to calculate correlation between two given sets of numbers. Example: x=[10.0, 10.8, 11.3, 10.0, 10.1, 11.1, 11.3, 10.2, 13.5, 12.3, 14.5, 11.0, 12.0, 11.8, 13.4, 11.4, 12.0, 15.6, 13.0, 12.1] y=[0.70, 0.73, 0.75, 0.70, 0.65,

Re: [Tutor] Buffering in file.read()

2008-05-12 Thread Dave Kuhlman
Kent Johnson tds.net> writes: > > Footnote 2.3 says, "Specifying a buffer size currently has no effect > on systems that don't have setvbuf(). The interface to specify the > buffer size is not done using a method that calls setvbuf(), because > that may dump core when called after any I/O has be

[Tutor] Using Python for accurate calculations

2008-05-12 Thread Gloom Demon
Hello I am working on a function which is going to calculate correlation between two given sets of numbers. Example: x=[10.0, 10.8, 11.3, 10.0, 10.1, 11.1, 11.3, 10.2, 13.5, 12.3, 14.5, 11.0, 12.0, 11.8, 13.4, 11.4, 12.0, 15.6, 13.0, 12.1] y=[0.70, 0.73, 0.75, 0.70, 0.65, 0.65, 0.70, 0.61, 0.70,