Re: [Tutor] hypotenuse

2008-03-13 Thread Brett Wilkins
import math math.sqrt(intNumber) Cheers, Brett > I am in an early lesson in "A Byte of Python." Instead of writing a > program > to find the area of a rectangle I thought it would be useful to write a > program to determine the length of the diagonal of a "golden rectangle", > which would of

Re: [Tutor] hypotenuse

2008-03-13 Thread John Fouhy
On 14/03/2008, Scott Kerr <[EMAIL PROTECTED]> wrote: > Hello, > > I am also new to python and programming. Since two have already posted that > you need to import math modules to do square roots, I am curious. > > Why can you not use something like: > > >>>hypotenuse = hyp_squared**1/2 > > or > >

Re: [Tutor] hypotenuse

2008-03-13 Thread Andreas Kostyrka
assert 4**0.5 == 2 More generally: nth root of x: x ** (1.0/n) Or even more generally, take the 3rd root of the square of x: x ** (2.0/3.0) And when we are already extending the scope of the mailing list to math basics: 1.0/(x**2) == x**-2 (negating the power gives the inverse.) Andreas Am

Re: [Tutor] hypotenuse

2008-03-13 Thread John Fouhy
On 14/03/2008, Robert Childers <[EMAIL PROTECTED]> wrote: > I am in an early lesson in "A Byte of Python." Instead of writing a program > to find the area of a rectangle I thought it would be useful to write a > program to determine the length of the diagonal of a "golden rectangle", > which would

Re: [Tutor] hypotenuse

2008-03-13 Thread Luke Paireepinart
Robert Childers wrote: > I am in an early lesson in "A Byte of Python." Instead of writing a > program to find the area of a rectangle I thought it would be useful > to write a program to determine the length of the diagonal of a > "golden rectangle", which would of course equal the sq root of

[Tutor] hypotenuse

2008-03-13 Thread Robert Childers
I am in an early lesson in "A Byte of Python." Instead of writing a program to find the area of a rectangle I thought it would be useful to write a program to determine the length of the diagonal of a "golden rectangle", which would of course equal the sq root of the sum of the squares of the widt

Re: [Tutor] Correct way to call an outside program?

2008-03-13 Thread Luke Paireepinart
Allen Fowler wrote: > Thank you for the help. :) > > - Original Message > > simplest way to run external commands ! > > import os > cmd="/usr/bin/ssh 10.0.0.20 uptime" > os.popen(cmd) This is deprecated in python 2.5+. Use subrpocess instead of os.popen to make sure y

Re: [Tutor] Simple reg-ex syntax?

2008-03-13 Thread Allen Fowler
findall is great. Thank you. :) - Original Message > From: Chris Fuller <[EMAIL PROTECTED]> > To: tutor@python.org > Sent: Thursday, March 13, 2008 5:10:43 AM > Subject: Re: [Tutor] Simple reg-ex syntax? > > > How I would improve this: > > compile the regular expression. This is more

Re: [Tutor] Correct way to call an outside program?

2008-03-13 Thread Allen Fowler
Thank you for the help. :) - Original Message simplest way to run external commands ! import os cmd="/usr/bin/ssh 10.0.0.20 uptime" os.popen(cmd) my cmd is just an example, use any cmd you want & its output will be displayed to you. hope this helps [SNIP] subprocess.Popen().com

Re: [Tutor] Hard time understanding classes

2008-03-13 Thread Ian Ozsvald
Hi Norm. Jerol created a 3-part video series on Python Objects, he uses IPython to talk about how and why they work: http://showmedo.com/videos/series?name=IntroductionToPythonObjectsUsingIPython_JerolH If you find his videos useful do please leave him a comment - authors love to know that thei

Re: [Tutor] Hello

2008-03-13 Thread Greg Graham
It appears to me that the following line would not work: >Circle = Oval(points) The variable "points" is a list of six points, and I don't know how one would define a circle or oval with 6 points. At the top part of your program, an oval is defined using two points, which makes sense. Maybe

[Tutor] Hello

2008-03-13 Thread Christopher Marlett
Hi, I'm in a Python class and we were given the assignment to create our own graphic and my idea was to have a program that asks the user to click six points and then create a circle using the six points they clicked. Once they've done that I want eyes and a mouth to appear in the circle. I was

Re: [Tutor] Hard time understanding classes

2008-03-13 Thread Norm All
Thank you for all the suggestions regarding my struggle to understand classes, I will follow up on all the links provided and continue to search. On Wed, Mar 12, 2008 at 5:12 PM, Ole Henning Jensen <[EMAIL PROTECTED]> wrote: > Norm All wrote: > > I am learning python and so far have done pretty

Re: [Tutor] Begining Python

2008-03-13 Thread Andreas Kostyrka
Am Mittwoch, den 12.03.2008, 09:39 +0100 schrieb Meftah Tayeb: > hi my friend, > i have active python installed and the python-Win is Ready > but i have a Very Small problem: > i am blind, and i am using a Screen reader > this screen reader use the Microsoft Active Accessibiliti (MSAA) to find >

Re: [Tutor] Correct way to call an outside program?

2008-03-13 Thread linuxian iandsd
simplest way to run external commands ! import os cmd="/usr/bin/ssh 10.0.0.20 uptime" os.popen(cmd) my cmd is just an example, use any cmd you want & its output will be displayed to you. hope this helps On Thu, Mar 13, 2008 at 12:05 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Allen Fowler

Re: [Tutor] Correct way to call an outside program?

2008-03-13 Thread Kent Johnson
Allen Fowler wrote: > Hello, > > I need to call an external command line .exe utility from my Python script. > > What is the best way to capture the output (if any) and (optionally) direct > it to my normal standard output? subprocess.Popen().communicate() will do it: In [1]: import subprocess

Re: [Tutor] Begining Python

2008-03-13 Thread Ian Ozsvald
Hi Meftah. Under the 'beginner programming' section of Python we have a lot of free video examples of Python coding: http://showmedo.com/videos/python?topic=beginner_programming and if you look under 'all' for Python: http://showmedo.com/videos/python?topic=all you'll find IDE videos on PyDev, SP

Re: [Tutor] Begining Python

2008-03-13 Thread Kent Johnson
Meftah Tayeb wrote: > hi my friend, > i have active python installed and the python-Win is Ready > but i have a Very Small problem: > i am blind, and i am using a Screen reader > this screen reader use the Microsoft Active Accessibiliti (MSAA) to find > informations about actual object in the scre

Re: [Tutor] Simple reg-ex syntax?

2008-03-13 Thread Chris Fuller
How I would improve this: compile the regular expression. This is more efficient. self.digit_extractor = re.compile('(\d+)') then, use the findall method: self.allNumbers = self.digit_extractor.findall(self.aString) which will even work with multiline strings, but doesn't convert to integers.