Re: [Tutor] Little problem with math module

2008-04-21 Thread Alan Gauld
"Tiago Katcipis" <[EMAIL PROTECTED]> wrote > def newton_divergente(x): > return math.pow(x, 1.0/3.0) > > but when x = -20 it returns this error > > return math.pow(x, 1.0/3.0) > ValueError: math domain error > > but why is that? is it impossible to calculate -20 ^ (1/3) ? It may be your us

[Tutor] Python WSDL Generation Tools

2008-04-21 Thread ryan d'mello
Hi all, I am using SOAPpy for generating web services .I have also written a client in python for accessing that web service ,and it works fine.Now when i try to make a java client to access the web service created in python ,the java client ask me for a wsdl file which is not present . So i want

Re: [Tutor] Little problem with math module

2008-04-21 Thread joe gallo
On Mon, Apr 21, 2008 at 12:07 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > > >>> pow(20, 0.333) > 2.7144173455393048 > >>> pow(-20, 0.333) > Traceback (most recent call last): > File "", line 1, in > ValueError: negative number cannot be raised to a fractional power > >>> -20**0.333 >

Re: [Tutor] Python WSDL Generation Tools

2008-04-21 Thread Kent Johnson
ryan d'mello wrote: > Hi all, > > I am using SOAPpy for generating web services .I have also written a > client in python for accessing that web service ,and it works fine.Now > when i try to make a java client to access the web service created in > python ,the java client ask me for a wsdl fi

[Tutor] HTML Parsing

2008-04-21 Thread Stephen Nelson-Smith
Hi, I want to write a little script that parses an apache mod_status page. I want it to return simple the number of page requests a second and the number of connections. It seems this is very complicated... I can do it in a shell one-liner: curl 10.1.2.201/server-status 2>&1 | grep -i request |

Re: [Tutor] HTML Parsing

2008-04-21 Thread Stephen Nelson-Smith
On 4/21/08, Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > As usual there are a number of ways. > > But I basically see two steps here: > > 1.) capture all dt elements. If you want to stick with the standard > library, htmllib would be the module. Else you can use e.g. > BeautifulSoup or somethi

Re: [Tutor] HTML Parsing

2008-04-21 Thread Andreas Kostyrka
As usual there are a number of ways. But I basically see two steps here: 1.) capture all dt elements. If you want to stick with the standard library, htmllib would be the module. Else you can use e.g. BeautifulSoup or something comparable. 2.) Check all dt contents either via regex, or with a .s

Re: [Tutor] HTML Parsing

2008-04-21 Thread Andreas Kostyrka
Just from memory, you need to subclass the HTMLParser class, and provide start_dt and end_dt methods, plus one to capture the text inbetween. Read the docs on htmllib (www.python.org | Documentation | module docs), and see if you can manage if not, come back with questions ;) Andreas Am Montag,

[Tutor] Computing factorial...

2008-04-21 Thread kinuthia muchane
Hi, I wanted to calculate the factorial of a given number without using recursion. I came up with the following code, although it is not very elegant it works. def factorial(*args): product = args[0] for item in args[1:]: product *= item return product number

Re: [Tutor] Little problem with math module

2008-04-21 Thread Dick Moores
At 07:40 PM 4/20/2008, John Fouhy wrote: >If you're going to be working with complex numbers, you might be >better off looking at scipy or some other module that provides more >mathematical grunt. Try mpMath () With version 0.7: >>> from mpmath import power, mp

Re: [Tutor] Computing factorial...

2008-04-21 Thread bob gailer
kinuthia muchane wrote: > Hi, > > I wanted to calculate the factorial of a given number without using > recursion. I came up with the following code, although it is not very > elegant it works. > > def factorial(*args): > > product = args[0] > for item in args[1:]: > produ

Re: [Tutor] HTML Parsing

2008-04-21 Thread bob gailer
Stephen Nelson-Smith wrote: > Hi, > > I want to write a little script that parses an apache mod_status page. > > I want it to return simple the number of page requests a second and > the number of connections. > > It seems this is very complicated... I can do it in a shell one-liner: > > curl 10.1.

Re: [Tutor] Hoping to benefit from someone's experience...

2008-04-21 Thread Hansen, Mike
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Marc Tompkins > Sent: Saturday, April 19, 2008 1:46 PM > To: tutor@python.org > Subject: Re: [Tutor] Hoping to benefit from someone's experience... > > > As you might expect, most of the time is s

Re: [Tutor] HTML Parsing

2008-04-21 Thread linuxian iandsd
Another horrid solution > #!/usr/bin/python > # line number does not change so we use that # the data we're looking for does not have a (unique) close tag (htmllib > ) > > import re, urllib2 > file=urllib2.urlopen('http://10.1.2.201/server-status') > n=0 > for line in file: > n=n+1 > if n=

Re: [Tutor] Little problem with math module

2008-04-21 Thread Dick Moores
At 08:17 AM 4/21/2008, Dick Moores wrote: >At 07:40 PM 4/20/2008, John Fouhy wrote: > >If you're going to be working with complex numbers, you might be > >better off looking at scipy or some other module that provides more > >mathematical grunt. > >Try mpMath () >

Re: [Tutor] HTML Parsing

2008-04-21 Thread bob gailer
Stephen Nelson-Smith wrote: > Hi, > > >> for lineno, line in enumerate(html): >> > > -Epython2.2hasnoenumerate() > > I used enumerate for a marginal (unproven) performance enhancement. > Can we code around this? for lineno in range(len(html)): x = html[lineno].find("requests/sec") i

Re: [Tutor] Hoping to benefit from someone's experience...

2008-04-21 Thread Jeff Younker
On Apr 15, 2008, at 11:33 PM, Alan Gauld wrote: > Have you considered driving Word instead of OOo? > That way you leave the documents in their original format > and make the mods using COM from Python. I've used this approach before, and I whole heartedly suggest that you look into it. The Win3

Re: [Tutor] HTML Parsing

2008-04-21 Thread Stephen Nelson-Smith
Hi, > for lineno, line in enumerate(html): -Epython2.2hasnoenumerate() Can we code around this? > x = line.find("requests/sec") > if x >= 0: >no_requests_sec = line[3:x] >break > for lineno, line in enumerate(html[lineno+1:]): > x = line.find("requests currently being processed"

Re: [Tutor] HTML Parsing

2008-04-21 Thread Jeff Younker
On Apr 21, 2008, at 6:40 AM, Stephen Nelson-Smith wrote: > On 4/21/08, Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > I want to stick with standard library. > > How do you capture elements? from xml.etree import ElementTree document = """ foo and bar foo

Re: [Tutor] Little problem with math module

2008-04-21 Thread ALAN GAULD
On Mon, Apr 21, 2008 at 12:07 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: >>> pow(-20, 0.333) Traceback (most recent call last): File "", line 1, in ValueError: negative number cannot be raised to a fractional power >>> -20**0.333 -2.7144173455393048 >>> I think you're confusing the orde

Re: [Tutor] HTML Parsing

2008-04-21 Thread Andreas Kostyrka
If you have a correct XML document. In practice this is rather a big IF. Andreas Am Montag, den 21.04.2008, 10:35 -0700 schrieb Jeff Younker: > On Apr 21, 2008, at 6:40 AM, Stephen Nelson-Smith wrote: > > > On 4/21/08, Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > > I want to stick with standard

Re: [Tutor] Little problem with math module

2008-04-21 Thread Tiago Katcipis
i will change the subject but this one is interessenting. i have this test code import funcoes import bissecao import falsa_posicao import falsa_posicaom import newton_simples import math INTERVALO = [0,1] ERRO_DET = math.pow(10, -16) ITER = funcoes.calcular_num_iteracoes(INTERVALO[0], INTERVALO

Re: [Tutor] HTML Parsing

2008-04-21 Thread Andreas Kostyrka
eeck. Not that I advocate parsing files by line, but if you need to do it: lines = list(file)[16:] or lines_iter = iter(file) zip(lines_iter, xrange(16)) for line in lines_iter: Andreas Am Montag, den 21.04.2008, 14:42 + schrieb linuxian iandsd: > Another horrid solution > > #!

[Tutor] Arguments ina separate file

2008-04-21 Thread Sanhita Mallick
Hi. I have a big list of arguments, which I would like to keep in a separate file. How do I pass arguments that are in a separate file? Thanks. San ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Arguments ina separate file

2008-04-21 Thread Tim Michelsen
> I have a big list of arguments, which I would like to > keep in a separate file. How do I pass arguments that > are in a separate file? do you mean like setting? do something like this write them in the file myargs.py import myargs call_my_function(myargs.argument1, myargs.argument2) see a

Re: [Tutor] Arguments ina separate file

2008-04-21 Thread linuxian iandsd
> > import myargs this one is clever ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] HTML Parsing

2008-04-21 Thread Kent Johnson
Stephen Nelson-Smith wrote: Hi, I want to write a little script that parses an apache mod_status page. I want it to return simple the number of page requests a second and the number of connections. The page looks like this: Apache Status Apache Server Status for 10.1.2.201 Server Versio

[Tutor] Why next vs. __next__ ?

2008-04-21 Thread python
Is there a reason why generators have a special method named "next" vs. "__next__"? All other Python's special names have the double underscore prefix/suffix. http://docs.python.org/ref/specialnames.html Are there other special names like "next" that don't have the double underscore delimiters?

Re: [Tutor] Hoping to benefit from someone's experience...

2008-04-21 Thread Michael Langford
Office VBA is pretty much the same objects as the Office COM object. You use the same for both, so probably can do it in python very close to the same speed as vba --Michael On Wed, Apr 16, 2008 at 1:48 PM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > Again with the forgetting to cc the lis

[Tutor] When to use % vs. locale.format()?

2008-04-21 Thread python
Are there any best practices guidelines that discuss when one should use % vs. locale.format? The locale.format() seems closer to the new new Python 3.0 print-as-a-function vs. statement ... with the added benefit of localized output. Malcolm ___ Tutor

Re: [Tutor] Little problem with math module

2008-04-21 Thread tiger12506
my problem is, INSIDE the funcion...the variable erro is correct, but when i return it to the test...and the test prints itcomes out 0.0. Its disturbing...i didnt found a way of solving this. err is defined in the function so it thinks it's a local variable. You can set it to change only th

Re: [Tutor] Why next vs. __next__ ?

2008-04-21 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Is there a reason why generators have a special method named "next" vs. "__next__"? All other Python's special names have the double underscore prefix/suffix. http://docs.python.org/ref/specialnames.html It's actually considered a mistake. The original rationale is sp

Re: [Tutor] When to use % vs. locale.format()?

2008-04-21 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Are there any best practices guidelines that discuss when one should use % vs. locale.format? You might want to try comp.lang.python if you don't get an answer here. Kent ___ Tutor maillist - Tutor@python.org http://mail.py

Re: [Tutor] Why next vs. __next__ ?

2008-04-21 Thread tiger12506
It's actually considered a mistake. The original rationale is spelled out in PEP 234 - see the Resolved Issues section: http://www.python.org/dev/peps/pep-0234/ It is being renamed to __next__() in Python 3.0 and there will be a builtin next() method that calls it. Instead of iterator.next()

Re: [Tutor] Little problem with math module

2008-04-21 Thread Kent Johnson
tiger12506 wrote: my problem is, INSIDE the funcion...the variable erro is correct, but when i return it to the test...and the test prints itcomes out 0.0. Its disturbing...i didnt found a way of solving this. err is defined in the function so it thinks it's a local variable. My reading i

Re: [Tutor] Little problem with math module

2008-04-21 Thread tiger12506
Hmm. I didn't read particularly closely, but it seemed that there were two different versions going on. The first examples more like what he wanted to happen, and the last example what he tried and didn't get to work. Since it's in a different module he can get around it by using global erro and

Re: [Tutor] Python WSDL Generation Tools

2008-04-21 Thread wesley chun
> I am using SOAPpy for generating web services .I have also written a client > in python for accessing that web service ,and it works fine.Now when i try > to make a java client to access the web service created in python ,the java > client ask me for a wsdl file which is not present . > > So i wa